On May 24, 2010, at 5:36 PM, <jyoun...@kc.rr.com> <jyoun...@kc.rr.com> wrote:

> I've been trying a few tests with IKImageView to view an EPS file with 
> zooming capabilities.  Some code that Apple provides works well... however 
> I'm getting a warning -> "warning: 'IKImageView' may not respond to 
> '-setImage:'".  Instead of using the NSURL (which doesn't seem to work with 
> EPS images in my tests), I'm using NSImage.  The IKImageView documentation 
> states:
> 
> -------------------
> You can provide an images for the view in any of these formats:
> 
> File reference (NSURL, CFURLRef, or a path)
> CGImageSourceRef
> Data (NSData or CFDataRef)
> Image (NSImage, CGImageRef, or CIImage)
> -------------------
> 
> Just curious why I'm getting this warning since I'm using a NSImage?  My next 
> thought was to convert the NSImage to a CGImageRef, but that looks pretty 
> in-depth.  I thought if I converted it, maybe I could use:
> 

Yeah, If you look further down in the documentation, you'll see that there IS 
no setImage: NSImage. I've been through this with Apple. Officially, this is a 
bug IN THE DOCUMENTATION. Any setImage: NSImage method that exists is 
undocumented and may be taken away.

I use this:

CGImageRef nsImageToCGImage(NSImage* image)
{
   NSData * imgData = [image TIFFRepresentation];
   CGImageRef imgRef = 0;
   if(imgData)
   {
       CGImageSourceRef imageSource = 
                    CGImageSourceCreateWithData((CFDataRef)imgData,  NULL);

       imgRef = CGImageSourceCreateImageAtIndex(imageSource, 0, NULL);
   }

   return imgRef;
}



Brian Postow
Senior Software Engineer
Acordex Imaging Systems

_______________________________________________

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 arch...@mail-archive.com

Reply via email to