簡體   English   中英

CGBitmapContext創建內存釋放責任

[英]CGBitmapContextCreate memory release responsibility

這就是我創建UIImage 我用calloc分配了piOutData 現在,當我最后調用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);

…當我最后調用CGImageRelease時,它將自動釋放piOutData嗎?

piOutData由您擁有。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM