2015-03-25 47 views
0

我試圖加載過濾器,以便從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]];

回答

0

在該線

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 
+0

我用一樣,它仍然崩潰。對於更大尺寸的圖像,它會崩潰。尺寸幾乎約5000 * 3000,你試過更大的圖像尺寸。它仍然不適合我 – Nishan29 2015-03-25 08:37:06