• 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
Creating a color image with NSBitmapImageRep and greyscale data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creating a color image with NSBitmapImageRep and greyscale data


  • Subject: Creating a color image with NSBitmapImageRep and greyscale data
  • From: Jason Horn <email@hidden>
  • Date: Tue, 27 Nov 2007 19:38:11 -0500

I need to create a color image from greyscale data. This is because I would like to display the image in false color to aid in visualization. I have tried using the CIColorMap core image filter on a CIImage created from a 16 bit greyscale NSBitmapImageRep, but this does not work (you just get a modified greyscale image, not color). Unfortunately, there is nothing in the documentation for CIColorMap that says you can only apply this filter to a color image, but I am assuming that that is the case. So, I though I would transform the greyscale image data into color RGB data and create a color NSBitmapImageRep, but this is not working either. Here's what I have:

NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:width
pixelsHigh:height
bitsPerSample:16
samplesPerPixel:3
hasAlpha:NO
isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bitmapFormat:0
bytesPerRow:3840
bitsPerPixel:48];
unsigned char *bitmapData = [bitmap bitmapData];
uint16_t RGBData[921600];
int pixel, color;
int numPixels = height*width;
for (pixel=0; pixel<numPixels; pixel++) {
for (color=0; color<3; color++) {
RGBData[pixel+color] = pixels[pixel];
}
}
memcpy(bitmapData, RGBData, [bitmap bytesPerRow] * [bitmap pixelsHigh]);


'pixels' is an array of 16 bit integers that contain the data for the 16 bit greyscale image that is 640 x 480. This code actually produces a three mini-greyscale images inside the main image.

Does anyone know hat I'm doing wrong? Any suggestions for creating a color image from greyscale data?

Thanks! _______________________________________________

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


  • Follow-Ups:
    • Re: Creating a color image with NSBitmapImageRep and greyscale data
      • From: David Spooner <email@hidden>
  • Prev by Date: Re: Distributed Objects and Leopard issue
  • Next by Date: Re: NSBrowser drawInteriorWithFrame called before willDisplayCell, causing display problems
  • Previous by thread: Re: Selections in NSCollectionView
  • Next by thread: Re: Creating a color image with NSBitmapImageRep and greyscale data
  • Index(es):
    • Date
    • Thread