I've looked around everywhere to no avail. I'm doing some image loading in a thread and since UIKit is not thread safe I'm going to have to store the images as CGImageRefs but I can't figure out how to do this. I haven't played with any of the Quartz stuff before so it's confusing me. Basically I just need to load a JPG from the disk into a CGImageRef. Also for bonus points, is there anyway to load a GIF into a CGImageRef?
+1
A:
I think the simplest way is to use UIKit and use the CGImage
propriety of UIImage
.
Something like that :
UIImage* image = [UIImage imageNamed:@"Your Image.png"];
CGImageRef imageRef = image.CGImage;
gcamp
2010-08-23 18:01:40
Okay but the point is, this is happening in a thread and UIKit is not thread safe. Otherwise I'd just send back the UIImage. I need to be able to read an image from a file and directly create a CGImageRef for it
Alexander
2010-08-23 18:04:16
Unfortunately the O.P. is right, that Apple says "All UIKit objects should be used on the main thread only."
Frank Schmitt
2010-08-23 18:04:39
If I'm not mistaken, UI updates should be done on the main thread. Other parts of UIKit are actually thread safe.
gcamp
2010-08-23 18:17:27
Yes UI updates should be done on the main thread, however I'm just LOADING images from disk (which is an expensive process on the UI thread) and no UIImages are not thread safe and thus the CGImageRefs
Alexander
2010-08-23 18:50:41