I am trying to read the ARGB pixels from a an image asset in iOS. For that, I need a CGImageRef I can use to get its CGDataProvider. My question is, if I create a CGImageRef using:
CGImageRef cg = [[UIImage imageNamed: Path] CGImage];
Will I eventually need to call CGImageRelease(cg)? If I don’t call CGImageRelease, will I have a memory leak?
Another issue I am having is that reading the same file for a second time returns an empty image, which I suspect might be because I didn’t call CGImageRelease the first time.
You have to call
CGImageReleaseonly when you useCGImageCreate,CopyorRetain(Or any such related method with create, copy, retain. For eg:-CGBitmapContextCreateImage). In this case, you dont have to do that since you are not doing any create, copy or retain.