1
이것은 내가 UIImage
을 생성하는 방법입니다. 나는 calloc으로 piOutData
를 할당했다. 이제 CGImageRelease
으로 전화하면 piOutData
이 자동으로 해제되거나 무료로 수동 처리해야합니다. 내가 마지막에 CGImageRelease를 호출 할 때CGBitmapContextCreate 메모리 릴리즈 책임
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);