2012-10-26 3 views
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); 

Répondre

1

... quand je l'appelle CGImageRelease à la fin, sera-t publiaient automatiquement piOutData?

Le numéro piOutData est la propriété de vous.

Questions connexes