Re: NSBitmapImageRep byte/color component ordering
Re: NSBitmapImageRep byte/color component ordering
- Subject: Re: NSBitmapImageRep byte/color component ordering
- From: Alastair Houghton <email@hidden>
- Date: Thu, 1 Nov 2007 10:43:30 +0000
On 1 Nov 2007, at 00:06, Brian Tarricone wrote:
When I do all this when the source image is a frame from the movie
itself, it works fine. However, when I do this for an image fetched
from amazon.com, the post-trimmed image has the colors messed up; it
looks like the raw bitmap data is BGRA (or maybe ABGR, not sure), but
the new NSBitmapImageRep I create expects RGBA, so, in the final
image, the green and red components are swapped.
I can think of two possible ways to solve this problem, neither of
which appears to be possible:
1. Convert the color order myself before copying the image data to
the new NSBitmapImageRep, or
2. Tell the new NSBitmapImageRep what color order to expect.
However, I can't seem to figure out how to 1) determine the color
order in the source NSBitmapImageRep, or 2) tell the destination
imagerep what color order the data is in. Any ideas? Am I missing
something here? I looked around in the list archives(*), and I found
a couple similar posts, but with no useful answers.
As far as I'm aware, NSBitmapImageRep only supports RGBA and ARGB (for
RGB data, that is). You can tell which using the -bitmapFormat
method, and you can set which using the bitmapFormat: argument when
creating a bitmap image rep.
If you're certain that the data you're seeing is BGRA, where are you
getting it from? If something is returning an NSBitmapImageRep
containing BGRA data, AFAIK that's wrong and you should file a bug
report.
Hopefully, though, it's just ARGB rather than RGBA and you can check
or tweak the bitmapFormat in your code.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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