Re: WebConvertNSImageToCGImageRef Issues
Re: WebConvertNSImageToCGImageRef Issues
- Subject: Re: WebConvertNSImageToCGImageRef Issues
- From: Chad Weider <email@hidden>
- Date: Wed, 18 Jan 2006 13:13:38 -0600
Ah, I think I've figured out the reason it won't work...
Looks to me like WebConvertNSImageToCGImageRef() requires that the
NSImage passed has a NSBitmapRep representation within it.
So if you use the following (as taken from the Dev. Docs):
http://developer.apple.com/documentation/Cocoa/Conceptual/DrawImages/
Tasks/CachingRepresentations.html
NSImage* image = [[NSImage alloc] initWithSize:size];
[image lockFocus];
// draw draw draw
NSBitmapImageRep* rep = [[NSBitmapImageRep alloc]
initWithFocusedViewRect:
NSMakeRect(0,0,size.width,size.height)];
[image unlockFocus];
and then load that image rep back into the NSImage:
[image addRepresentation:rep];
Things should work properly (at least they have in my case)
Chad Weider
email@hidden
On Jan 16, 2006, at 10:49 AM, John Pannell wrote:
Hi Chad-
Thanks for the code, though really I need some way to deal with
arbitrary NSImages.
You can replace the PNG specific call in my function with the more
generic CGImageCreate, or any of the CGImageSourceCreate* functions
if you are targeting Tiger. There is also
GraphicsImportCreateCGImage, which uses QuickTime to import the
image. I went with the PNG solution because it required few
parameters compared to the other functions. All are documented in
the XCode documentation.
For anyone interested in CoreGraphics, I cannot speak highly enough
a book announced in one of Apple's recent developer newsletters:
Programming with Quartz, by Gelphman and Laden. Well written,
concise, many examples... it is a very good book for anyone
interested in the drawing mechanics underlying Cocoa and Carbon.
Hope this helps!
John
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden