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

Re: Creating a color image with NSBitmapImageRep and greyscale data


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

Thanks Dave,

I was aware that the code I gave will still give a grey image. The problem is that the image is also munged somehow. the resulting image was actually a mosaic of three separate grey images within the borders of the main image,with the rest of the space being black. Also, the reason that I was attempting this was in hopes that, even though technically still grey, CIColorMap would treat the image differently, and yield a color image.


On Nov 27, 2007, at 10:55 PM, David Spooner wrote:


Sorry, I meant to also say that an alternative to this quick and dirty approach is to consider the input greyscale value as the hue component of an HSB (or related) colorspace and perform a standard conversion from HSB to RGB (using a fixed saturation and brightness).


dave

On 27-Nov-07, at 8:34 PM, David Spooner wrote:

The preceding line sets the r, g and b components uniformly for each output pixel, so you'll always get grey. You might try distributing each input pixel p across r, g and b along the lines of...

int bpr = [bitmap bytesPerRow];

for (int i = 0; i < height; ++i) {
char *row = bitmapData + i * bpr;
for (int j = 0; j < width; ++j) {
  uint16_t p = pixels[i * width + j];
  unsigned char *rgb = row + j * 3;
  rgb[0] = p & 0x3f;
  rgb[1] = (p >> 6) & 0x3f;
  rgb[2] = (p >> 12);
}
}

_______________________________________________

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

_______________________________________________

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


References: 
 >Creating a color image with NSBitmapImageRep and greyscale data (From: Jason Horn <email@hidden>)
 >Re: Creating a color image with NSBitmapImageRep and greyscale data (From: David Spooner <email@hidden>)
 >Re: Creating a color image with NSBitmapImageRep and greyscale data (From: David Spooner <email@hidden>)

  • Prev by Date: Re: Creating a color image with NSBitmapImageRep and greyscale data
  • Next by Date: Re: Creating a color image with NSBitmapImageRep and greyscale data
  • Previous by thread: Re: Creating a color image with NSBitmapImageRep and greyscale data
  • Next by thread: Re: Creating a color image with NSBitmapImageRep and greyscale data
  • Index(es):
    • Date
    • Thread