我在记忆中有一张照片,但我如何获得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];