Drawing a grayscale Icon
-
I am trying to create a grayscale version of an icon. I have extracted the icon and have an HICON but how would I create a grayscale version? I have been trying to figure it out and it seems I need to create an HDC and draw the icon into that but I am new to graphics and am a bit lost...
-
I am trying to create a grayscale version of an icon. I have extracted the icon and have an HICON but how would I create a grayscale version? I have been trying to figure it out and it seems I need to create an HDC and draw the icon into that but I am new to graphics and am a bit lost...
-
hIconGrey = ::CopyImage( hIcon, IMAGE_ICON, 32, 32, LR_MONOCHROME ); too easy too find it :doh:
Greetings from Germany
-
I am trying to create a grayscale version of an icon. I have extracted the icon and have an HICON but how would I create a grayscale version? I have been trying to figure it out and it seems I need to create an HDC and draw the icon into that but I am new to graphics and am a bit lost...
You need to convert RGB values to grayscale values. The typically formula used is BYTE 8bitGrayscaleValue = (0.30 * RedByte) + (0.59 * GreenByte) + (0.11 * BlueByte) or the integer (no floating point) version: BYTE 8bitGrayscaleValue = (BYTE)((((int)RedByte * 30) + ((int)GreenByte * 59) + ((int)BlueByte * 11)) / 100); You could create a 24bpp DIB section the dimensions of the icon, select it into a memory DC, and draw the icon on the memory DC. Then using the pointer to the DIBSection's pixel bits, iterate through the RGB pixel values, converting each to grayscale. That's the easiest way I can think of to access the pixel data of an icon. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
I am trying to create a grayscale version of an icon. I have extracted the icon and have an HICON but how would I create a grayscale version? I have been trying to figure it out and it seems I need to create an HDC and draw the icon into that but I am new to graphics and am a bit lost...
Also, this may help: CreateGrayscaleIcon[^] The use of GetPixel() and SetPixel() are way slower than accessing pixel data directly as I proposed in my previous post, if that's an issue. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: