2011-11-29 68 views
1

我需要将CIImage转换为可写入磁盘的格式。将ciimage转换为可写格式

当前我正在使用下面的代码将其转换为JPG格式。

NSBitmapImageRep* rep = [[[NSBitmapImageRep alloc] initWithCIImage:result] autorelease]; 

NSData *JPEGData = [rep representationUsingType:NSJPEGFileType properties:nil]; 
[JPEGData writeToFile:targetPath atomically:YES]; 

但真正的内存使用率高达100 MB以上。我的应用程序需要我处理大量图像,所以我需要优化内存使用情况。

任何人都可以请任何建议?

回答

0

如果它是累积的内存是一个问题,而不仅仅是一个形象,你可以尝试包裹在自己的自动释放池的最后两行:

@autoreleasepool { 
    NSData *JPEGData = [rep representationUsingType:NSJPEGFileType properties:nil]; 
    [JPEGData writeToFile:targetPath atomically:YES]; 
} 
+0

我已经保持一个自动释放池里面这些语句。 。但问题仍然存在 –

+0

我承认我不确定,那么。 – Wevah