Ios CGBitmapContextCreate内存释放责任
这就是我创建Ios CGBitmapContextCreate内存释放责任,ios,memory-management,cgbitmapcontext,Ios,Memory Management,Cgbitmapcontext,这就是我创建UIImage的方法。我用calloc分配了piOutData。现在,当我最后调用CGImageRelease时,它会自动释放piOutData还是我需要通过free手动释放 int m_iH = iInMaxDim; int m_iW = iInMaxDim; UInt8*piOutData = calloc(iInMaxDim *iInMaxDim*4,sizeof(UInt8)); CGContextRef ctx = CGBitmapContextCreate(piOutD
UIImage
的方法。我用calloc分配了piOutData
。现在,当我最后调用CGImageRelease
时,它会自动释放piOutData
还是我需要通过free手动释放
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
归您所有
…当我最后调用CGImageRelease时,它会自动释放piOutData吗
否。piOutData
归您所有