0

我在内存中有一个图片点,但是如何获得 UIImage?

我尝试了以下两种方法并使用“UIImageWriteToSavedPhotosAlbum(myImage, self, nil, nil);” 将图像保存到我的相册,但它不起作用。我该如何解决这个问题?

第一的:

NSData *imageData = [[NSData alloc]initWithBytes:texture->data  length:picSize];
UIImage* myImage = [ [ UIImage alloc ]initWithData:imageData ];

第二:

CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, texture->data, texture->image_size.width * texture->image_size.height * texture->bytesPerPixel, NULL);
// prep the ingredients
int bitsPerComponent = 8;
int bitsPerPixel = 32;
int bytesPerRow = 4 * 320;
CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;
// make the cgimage
CGImageRef imageRef = CGImageCreate(320, 480, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent);
UIImage *myImage = [UIImage imageWithCGImage:imageRef];
4

0 回答 0