Re: NSBitmapImageRep byte/color component ordering
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