2

我想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为进一步的图像处理。

4

0 回答 0