On Oct 21, 2008, at 8:50 AM, Jean-Daniel Dupas wrote:
I'd like to put an image stored in a JPEG file onto a CALayer. It
seems that I do this by assigning a CGImageRef to its contents
property. But how do I get a CGImageRef from a file? Do I make an
NSData object from the file and do something with that?
dkj
You use ImageIO Framework. See CGImageSource reference.
Specifically, you would do something like this:
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForImageResource:@"myImage"]];
CGImageSourceRef source = CGImageSourceCreateWithURL((CFURLRef)url,
NULL);
CGImageRef image = CGImageSourceCreateImageAtIndex(source, 0, NULL);
CFRelease(source);
Do what you will with 'image' and release it when your done.
--
David Duncan
Apple DTS Animation and Printing
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]