我想CGBitmapContextCreate
用 texture->data 调用来创建一个CGContextRef
,并CGImageRef
通过CGBitmapContextCreateImage
(上下文)创建一个。
但是,创建的图像并不像预期的那样:(
创建自CGBitmapContextCreateImage
:
实际的(略有不同,因为我用另一台相机拍摄):
代码: ( texture.bytesPerPixel = 2
)
CGContextRef context = CGBitmapContextCreate(texture.data, 512, 512, 5, 512 * texture.bytesPerPixel, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipFirst);
CGImageRef cg_img = CGBitmapContextCreateImage(context);
UIImage* ui_img = [UIImage imageWithCGImage: cg_img];
UIImageWriteToSavedPhotosAlbum(ui_img, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
完整代码:
http://ihome.ust.hk/~tm_lksac/OpenGLSprite.m
应用程序通常调用- (void)drawSelfIfNeeded:(BOOL)
需要更新应用程序中的纹理。但我想对纹理进行“截图”并将其保存UIImage
为进一步的图像处理。