我使用下面的代码到电影的图像保存到我的桌面:错误节省NSImage中作为NSData的
NSCIImageRep *imageRep = [NSCIImageRep imageRepWithCIImage:[CIImage imageWithCVImageBuffer:imageBuffer]];
NSImage *image = [[[NSImage alloc] initWithSize:[imageRep size]] autorelease];
[image addRepresentation:imageRep];
CVBufferRelease(imageBuffer);
NSArray *representations = [image representations];
NSData *bitmapData = [NSBitmapImageRep representationOfImageRepsInArray:representations usingType:NSJPEGFileType properties:nil];
[bitmapData writeToFile:@"/Users/ricky/Desktop/MyImage.jpeg" atomically:YES];
在代码的倒数第二行,我收到以下消息在控制台中,用没有结果被保存到桌面:
<Error>: CGImageDestinationFinalize image destination does not have enough images
CGImageDestinationFinalize failed for output type 'public.jpeg'
的NSImage中仍然是整个方法调用的分配对象,所以我不知道为什么我收到有关的图像数量不足的投诉。
我很感激任何帮助。 在此先感谢, 瑞奇。
谢谢Jess。你的解决方案效果很好。臂,感谢您的帖子。 虽然我们在这里,有没有人知道在将图像保存到磁盘之前是否有水平翻转图像的方法? 再次感谢。 瑞奇。 – Ricky 2010-02-27 00:42:49