COLORREF to grayscale 
Author Message
 COLORREF to grayscale

Hi,

I'm working on an application tha loads and processes images.

I read raw data of grayscale images and try to display it with set Pixel in
my view. I cast the grayscale intensities of the image to type COLORREF. The
result is a red image. How can I fix that to see grayscale?

Thanks a lot.

Ralf.



Fri, 22 Jun 2001 03:00:00 GMT  
 COLORREF to grayscale

Quote:

>Hi,

>I'm working on an application tha loads and processes images.

>I read raw data of grayscale images and try to display it with set Pixel in
>my view. I cast the grayscale intensities of the image to type COLORREF. The
>result is a red image. How can I fix that to see grayscale?

>Thanks a lot.

>Ralf.

I assume by "grayscale intensity", you mean a number from 0 to 255.
Simply casting that to COLORREF would get you a red from extremely
pale to extremely intense. You are telling the computer to interpret
this number as a RGB( Red, Green Blue) color. But you have Blue = 0,
Green = 0, Red = whatever the value was.

So, instead of that, use RGB(value, value, value). Give it the same
value all three times. That results in identical intensities of red,
green and blue. And that makes gray! The higher the value, the lighter
the gray. So using that method, you can display 256 values of gray.

--
Tim Slattery
MS MVP(DTS)



Fri, 22 Jun 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. inverse of a COLORREF value

2. COLORREF help please..

3. CImageList.Add Method - Do I need the bmpMask or COLORREF

4. 16 bit grayscale

5. COLORREF

6. how to draw grayscale image?

7. Print in color or grayscale ?

8. Blit Grayscale Image

9. BitBlt & Grayscale Images

10. COLORREF to RGBTRIPLE?

11. ColorRef

12. Grayscale bitmap

 

 
Powered by phpBB® Forum Software