How to grey an image on a e.g. a custom button?
Thanks,
Ole
You need a separate image with the grey colors and you paint it instead of
the color version when you want.

Signature
Chris Tacke - Embedded MVP
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--
> How to grey an image on a e.g. a custom button?
>
> Thanks,
> Ole
Here's a simple algorithm for doing greyscale:
static public Bitmap BitmapGrayScaleWeighted(Bitmap colorBitmap)
{
if (colorBitmap == null)
throw new ArgumentNullException("colorBitmap",
"ImageTools.BitmapGrayScaleWeighted");
Bitmap grayBitmap = new Bitmap(colorBitmap.Width, colorBitmap.Height);
Color colorPixel;
int newRGB;
for (int y = 0; (y < colorBitmap.Height); y++)
for (int x = 0; (x < colorBitmap.Width); x++)
{
colorPixel = colorBitmap.GetPixel(x, y);
newRGB = (int)((0.212671 * colorPixel.R) + (0.715160 * colorPixel.G) +
(0.072169 * colorPixel.B));
grayBitmap.SetPixel(x, y, Color.FromArgb(newRGB, newRGB, newRGB));
}
return grayBitmap;
}
-peter