質問

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