这就是我创建UIImage
. piOutData
我用calloc分配。现在当我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);