• 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: RGB-data (565 mode)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >NSBitmapImageRep: RGB-data (565 mode) (From: Mike Smith <email@hidden>)

  • Prev by Date: DO and NSProxy
  • Next by Date: Stopping the clip
  • Previous by thread: NSBitmapImageRep: RGB-data (565 mode)
  • Next by thread: Re: Cocoa-dev Digest, Vol 2, Issue 1006
  • Index(es):
    • Date
    • Thread