Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSBitmapImageRep: RGB-data (565 mode)



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: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >NSBitmapImageRep: RGB-data (565 mode) (From: Mike Smith <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.