繪製當我試圖繪製PNG圖片的透明度,使用OpenGL,我得到一個奇怪的黑色邊框周圍:黑色邊框,用OpenGL
但原始圖像乾淨,正常:
我的代碼:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
UIImage* allIcons = [[appDelegate load_image_from_zip: pl.icons[ico_index]] retain];
CGRect rect = CGRectMake(0, 0, allIcons.size.width/nIcons, allIcons.size.height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextTranslateCTM (currentContext, 0, allIcons.size.height);
CGContextScaleCTM (currentContext, 1, -1);
CGRect clippedRect = CGRectMake(0, 0, rect.size.width, rect.size.height);
CGContextClipToRect(currentContext, clippedRect);
CGRect drawRect = CGRectMake(rect.origin.x * -1, rect.origin.y * -1, allIcons.size.width, allIcons.size.height);
CGContextDrawImage(currentContext, drawRect, allIcons.CGImage);