Re: NSBitmapImageRep: RGB-data (565 mode)
Re: NSBitmapImageRep: RGB-data (565 mode)
- Subject: Re: NSBitmapImageRep: RGB-data (565 mode)
- From: Troy Stephens <email@hidden>
- Date: Thu, 30 Jun 2005 11:03:41 -0700
On Jun 29, 2005, at 3:24 PM, Mike Smith wrote:
Hi list,
I am having trouble creating NSImage from raw RGB data (565 mode). To
my understanding that NSBitmapImageRep initWithBitmapDataPlanes only
supports aligned bps.
How can I create a bitmap image from RGB data 585 mode?
Any sample code or suggestion will be greatly appreciated.
Thanks,
Mike
NSBitmapImageRep doesn't intrinsically support RGB 565-format pixel
data; you'll need to first promote the data to RGB 888.
A useful trick is to replicate the high bits of each original sample
value in the low bits of the new value. For the 5-bit 'R' and 'B'
samples, for example, you'd shift the original value left 3 bits, and
OR that with its top 3 bits, shifted down into the low 3 bit-positions:
new = (old << 3) | (old >> 2)
--
Troy Stephens
Cocoa Frameworks
Apple Computer, Inc.
_______________________________________________
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