Tuesday, January 17, 2012

How to Convert an Image to Grey scale in WPF

 

Converting images to grey scale is a nice trick to bring elements to user attention by “turning off” other elements. You could use a trick like this to “activate” or “deactivate” an element. Anyways, here is how you change an image to grey scale in WPF:

img.Source =
    new FormatConvertedBitmap(
             (BitmapSource)img.Source,
             PixelFormats.Gray16,
             BitmapPalettes.Gray16, 0
    );

Hope it helps !

No comments:

Post a Comment