绘制当我试图绘制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);