[英]CGBitmapContextCreate memory release responsibility
This is how I create a UIImage
. 这就是我创建
UIImage
。 I allocated piOutData
with calloc. 我用calloc分配了
piOutData
。 Now when I call CGImageRelease
at the end, will it automatically release piOutData
or I need to do it manually via free. 现在,当我最后调用
CGImageRelease
时,它将自动释放piOutData
还是我需要通过免费手动进行操作。
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?
…当我最后调用CGImageRelease时,它将自动释放piOutData吗?
No. piOutData
is owned by you. 否
piOutData
由您拥有。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.