>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.
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.