核心图像过滤器崩溃问题
问题描述:
我试图加载过滤器,以便从Web搜索下载的尺寸接近5000 * 3000的较大图像尺寸。将这些滤镜应用于较大图像尺寸时,应用程序会崩溃并因此终止。下面是我使用目前用于过滤器的预览其中的代码:下面核心图像过滤器崩溃问题
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]];
答
在该线
CGImageRef cgimg = [上下文createCGImage:outputImage fromRect:[outputImage程度]];
您创建一个新的形象的参考,然后从这个基准塑造新形象
尝试添加你的最后一行下面这条线
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,你试过更大的图像尺寸。它仍然不适合我 – Nishan29 2015-03-25 08:37:06