• 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
Re: Image conversion to RGBA colors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Image conversion to RGBA colors


  • Subject: Re: Image conversion to RGBA colors
  • From: Ken Ferry <email@hidden>
  • Date: Thu, 16 Dec 2010 20:09:25 -0800

On Thu, Dec 16, 2010 at 7:48 PM, Gideon King <email@hidden> wrote:

> Hi, I have an arbitrary (user supplied) image, and I want to get the RGBA
> values of each pixel of the image. I'm thinking that I should create it as
> an NSImage and then use the TIFFRepresentation to get it into an
> NSBitmapImageRep object, and then walk through and pick up the colors, but
> it appears that the NSBitmapImageRep could be in a wide variety of internal
> formats.
>
> Is there either some generic way of finding the RGBA values, or ensuring
> that the NSBitmapImageRep is created in a fixed color space that I can code
> for? ...or some other way of solving this problem?
>

Yes.  Create an NSBitmapImageRep in a fixed pixel format and draw the
NSImage in it.  Now you have bits in a canonical pixel format.

The TIFFRepresentation thing is a not very good hack that unfortunately
seems to have critical mass in the community - that code just won't die.
 TIFFRepresentation is good method to call if you're sending data outside of
your process, say to the pasteboard or to disk.  It's pretty much always
wrong if the data isn't going to leave your address space.

See the section "NSBitmapImageRep: CoreGraphics impedance matching and
performance notes" in the AppKit release
notes<http://developer.apple.com/library/mac/#releasenotes/Cocoa/AppKit.html>for
more detail.

-Ken
Cocoa Frameworks


>
> Thanks
>
> Gideon
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Image conversion to RGBA colors
      • From: Gideon King <email@hidden>
References: 
 >Image conversion to RGBA colors (From: Gideon King <email@hidden>)

  • Prev by Date: Image conversion to RGBA colors
  • Next by Date: Re: ImageAndTextCell editing problem
  • Previous by thread: Image conversion to RGBA colors
  • Next by thread: Re: Image conversion to RGBA colors
  • Index(es):
    • Date
    • Thread