• 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: NSBitmapImageRep byte/color component ordering
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSBitmapImageRep byte/color component ordering


  • Subject: Re: NSBitmapImageRep byte/color component ordering
  • From: "Brian Tarricone" <email@hidden>
  • Date: Thu, 1 Nov 2007 12:16:37 -0700

On Nov 1, 2007 11:33 AM, Benjamin Stiglitz <email@hidden> wrote:
> >> If you're certain that the data you're seeing is BGRA, where are you
> >> getting it from?
> >
> > An NSImage, -TIFFRepresentation.  (The NSImage was created with
> > -initFromContentsOfURL:.)  Note that this source NSImage displays
> > correctly in a NSImageView.  No, I'm not 100% sure it's BGR, but
> > that's the only explanation I can come up with for the blue and red
> > colors being reversed when I copy the pixels to the new imgrep (which
> > presumably expects ARGB/RGBA only).  Gonna start sampling known pixels
> > from the input to see what's going on.
>
> Uncompressed TIFFs are BGR.

It doesn't seem consistent though, AFAICT.  This returns a 24bpp RGB image:

QTMovieView *movieView = ....;  // video is loaded into this
NSImage *img = [movieView currentFrameImage];
NSBitmapImageRep *qtImgRep = [img
TIFFRepresentationUsingCompression:NSTIFFCompressionNone

                                                           factor:0];

Whereas this returns a 24bpp BGR image:

NSURL *url = ...;  // loaded with URL point to jpeg image via http
NSImage *img = [[NSImage alloc] initWithContentsOfURL:url];
NSBitmapImageRep *urlImgRep = [img
TIFFRepresentationUsingCompression:NSTIFFCompressionNone

                                                           factor:0];

(Sorry, I said before I was just using -[NSImage TIFFRepresentation],
but I made a mistake!)

How can I tell the difference?

> Try -[NSBitmapImageRep initWithData:].

How does -initWithData: know the image format (bpp, alpha or no alpha,
etc.)?  I have raw pixels here; no tiff/bmp/etc. header.

Thanks,
Brian
_______________________________________________

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

References: 
 >Re: NSBitmapImageRep byte/color component ordering (From: Alastair Houghton <email@hidden>)
 >Re: NSBitmapImageRep byte/color component ordering (From: "Brian Tarricone" <email@hidden>)
 >Re: NSBitmapImageRep byte/color component ordering (From: Benjamin Stiglitz <email@hidden>)

  • Prev by Date: Re: Localized country name from iso country code
  • Next by Date: Re: Leopard: Multiple Sheets Per Window Bug
  • Previous by thread: Re: NSBitmapImageRep byte/color component ordering
  • Next by thread: Re: NSBitmapImageRep byte/color component ordering
  • Index(es):
    • Date
    • Thread