1
Voici comment créer un UIImage
. J'ai alloué piOutData
avec calloc. Maintenant, quand j'appelle CGImageRelease
à la fin, va-t-il automatiquement libérer piOutData
ou je dois le faire manuellement par l'intermédiaire de libre.CGBitmapContextCréer la responsabilité de la libération de la mémoire
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);