【问题标题】:Core Image Filter Crash issue核心图像过滤器崩溃问题
【发布时间】:2015-03-25 05:38:54
【问题描述】:

我正在尝试为尺寸接近 5000*3000 的较大图像尺寸加载过滤器,这些图像尺寸是我从 Web Search 下载的。当为较大的图像尺寸应用这些过滤器时,应用程序崩溃并因此终止。以下是我目前用于预览过滤器的代码:

CIContext *context = [CIContext contextWithOptions:nil];
CIImage *outputImage = [filter.filter outputImage];
CGImageRef cgimg = [context createCGImage:outputImage fromRect:[outputImage extent]];
UIImage *displayImage = [UIImage imageWithCGImage:cgimg];

下面的代码行导致了这个问题,有人遇到过这个问题吗?

CGImageRef cgimg = [context createCGImage:outputImage fromRect:[outputImage extent]];

【问题讨论】:

    标签: ios objective-c iphone ios7 ios8


    【解决方案1】:

    在这一行

    CGImageRef cgimg = [context createCGImage:outputImage fromRect:[outputImage extent]];

    您创建一个新的图像引用,然后从该引用创建一个新图像

    尝试将此行添加到最后一行的下方

    CGImageRelease(cgimg)

    由于 ARC 没有自动释放这个引用,所以你必须手动释放这个引用,然后它会在你身边工作

    代码:

    CIContext *context = [CIContext contextWithOptions:nil];
    CIImage *outputImage = [filter.filter outputImage];
    CGImageRef cgimg = [context createCGImage:outputImage fromRect:[outputImage extent]];
    UIImage *displayImage = [UIImage imageWithCGImage:cgimg];
    CGImageRelease(cgimg);  // this line release the image reference
    

    【讨论】:

    • 我也用过,还是崩溃。对于更大尺寸的图像,它会崩溃。尺寸接近 5000*3000,你尝试过更大的图像尺寸吗?它仍然对我不起作用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多