【问题标题】:convert ciimage to writable format将 ciimage 转换为可写格式
【发布时间】:2011-11-29 13:59:10
【问题描述】:

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

目前我正在使用以下代码将其转换为 JPG 格式。

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

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

但实际内存使用量会高达 100 MB 以上。我的应用程序需要我处理大量图像,因此我需要优化内存使用。

谁能给点建议???

【问题讨论】:

    标签: objective-c image quartz-graphics core-image


    【解决方案1】:

    如果是累积内存问题,而不仅仅是一张图片,您可以尝试将最后两行包装在您自己的自动释放池中:

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

    【讨论】:

    • 我已经将这些语句保存在自动释放池中......但问题仍然存在
    • 我承认我不确定,那么。
    猜你喜欢
    • 1970-01-01
    • 2020-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-24
    • 2023-03-16
    相关资源
    最近更新 更多