• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Converting CGImageRefs to NSImages, how?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Converting CGImageRefs to NSImages, how?


  • Subject: Converting CGImageRefs to NSImages, how?
  • From: Ken Tozier <email@hidden>
  • Date: Sun, 24 Apr 2005 20:05:02 -0400

Sorry if this is an easy one but a thorough search of the list archives and the web didn't yield anything of much help.

I'm trying to convert a CGImageRef returned from "[context createCGImage: img fromRect: imgRect]"
to an NSImage so it can be used as the image in a drag operation but can't find any way to do the conversion.

The closest I've gotten is to attempt creating an NSBitmapImageRep using it's 

"initWithBitmapDataPlanes:(unsigned char **)planes 
    pixelsWide:(int)width 
    pixelsHigh:(int)height 
    bitsPerSample:(int)bps 
    samplesPerPixel:(int)spp 
    hasAlpha:(BOOL)alpha 
    isPlanar:(BOOL)isPlanar 
    colorSpaceName:(NSString *)colorSpaceName 
    bytesPerRow:(int)rowBytes 
    bitsPerPixel:(int)pixelBits"

method but since CFImageRef  is an opaque type, there doesn't seem to be any way to get a pointer to the data or extract the name of the color space. Everything else has an accessor function.

Has anyone else tried to do this type of conversion? If so, how did you do it?

Thanks

Ken
 _______________________________________________
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

  • Follow-Ups:
    • Re: Converting CGImageRefs to NSImages, how?
      • From: Andrew Platzer <email@hidden>
    • Re: Converting CGImageRefs to NSImages, how?
      • From: "Sean McBride" <email@hidden>
    • [Solved]: Converting CGImageRefs to NSImages, how?
      • From: Ken Tozier <email@hidden>
  • Prev by Date: Re: Java vs. Objective-C for Cocoa
  • Next by Date: Re: Conceptual help with CFMessagePort/NSMessagePort
  • Previous by thread: Re: Setting a blank ("") argument in NSTask
  • Next by thread: [Solved]: Converting CGImageRefs to NSImages, how?
  • Index(es):
    • Date
    • Thread