문제

This is how I create a UIImage. I allocated piOutData with calloc. Now when I call CGImageRelease at the end, will it automatically release piOutData or I need to do it manually via free.

int m_iH = iInMaxDim;
int m_iW = iInMaxDim;

UInt8*piOutData = calloc(iInMaxDim *iInMaxDim*4,sizeof(UInt8));
CGContextRef ctx = CGBitmapContextCreate(piOutData,  
                                         m_iW,  
                                         m_iH,  
                                             CGImageGetBitsPerComponent(inImage.CGImage),
                                         m_iW*4,  
                                         CGImageGetColorSpace(inImage.CGImage),  
                                         CGImageGetBitmapInfo(inImage.CGImage) 
                                         ); 
CGImageRef imageRef = CGBitmapContextCreateImage(ctx);  
CGContextRelease(ctx);
UIImage *finalImage = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
도움이 되었습니까?

해결책

…when I call CGImageRelease at the end, will it automatically release piOutData?

No. piOutData is owned by you.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top