我正在使用以下代码将一帧电影保存到我的桌面:
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 仍然是整个方法调用的分配对象,所以我不确定为什么我会收到有关图像数量不足的投诉。
我会很感激任何帮助。在此先感谢,瑞奇。