views:

75

answers:

2

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
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
Unfortunately the O.P. is right, that Apple says "All UIKit objects should be used on the main thread only."
Frank Schmitt
If I'm not mistaken, UI updates should be done on the main thread. Other parts of UIKit are actually thread safe.
gcamp
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
+1  A: 
Jerry Jones