Use a color matrix to grayscale. See below:
... code snippet...
Gdiplus::ImageAttributes imAtt;
Gdiplus::ColorMatrix gscale = {
0.30f, 0.30f, 0.30f, 0.00f, 0.00f,
0.59f, 0.59f, 0.59f, 0.00f, 0.00f,
0.11f, 0.11f, 0.11f, 0.00f, 0.00f,
0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
0.00f, 0.00f, 0.00f, 0.00f, 1.00f };
imAtt.SetColorMatrix( &gscale, Gdiplus::ColorMatrixFlagsDefault,
Gdiplus::ColorAdjustTypeBitmap );
g->DrawImage( pImg,
Gdiplus::Rect( 0, 0, dwWidth, dwHeight), // dest rect
0, 0, pImg->GetWidth(), pImg->GetHeight(), // source rect
Gdiplus::UnitPixel,
&imAtt);
...
When you are done, you may create a PixelFormat16bppRGB555 image and then
use
DrawImage to convert from PixelFormat24bppRGB to PixelFormat16bppRGB555.
Post by kkirtacSo, no way to change an image to gray level? do i have a chance to retrieve a
specific pixel's A, R, G, B values so that i can make an arithmetic operation
to construct a new image, i ll add those values and will divide the result by
4 and that value will be my new value of that pixel, only 1 value for a
pixel, thanks for help
Post by Michael Phillips, Jr.Format16bppGrayScale is not supported!
Post by kkirtacIs there a way to change the PixelFormat of the image? i get the
picture
into
the PictureBox and its PixelFormat is Format24bppRgb, and i want to
change
it
to Format16bppGrayScale ; i need it with grayscale format..any help is
appreciated, thanks.