Convert BitmapImage to Grayscale and Preserve Alpha

I am having a problem converting BitmapImage (WPF) to grayscale while preserving the alpha channel. The original image is PNG.

The MSDN article works fine here , but it removes the alpha channel.

Is there a quick and efficient way to convert BitmapImage to grayscale?

+5
source share
4 answers

You should take a look at image conversion using matrices.

, , ColorMatrix. ( VB.NET, #).

, -, , , .

+2

PixelFormat. , PixelFormats.Bgra32 , PixelFormats.Gray16. Gray16 . 65535 , .

. - Bgra32 , . , -. , 8- - ( ).

- , PixelFormats.Indexed8, , , , . , ( ), 1 255.

+2

API . " ": RGBA , RGBA MMMA, M = (R + G + B)/3;

, , RGB. , , .

+1

, ShaderEffect . , . , . , . , , .

HLSL LOB.:)

0

All Articles