32 bitmap and gdi+ problem
-
I have a 32bit bitmap with alpha channnel . I am drawing it using gdi+ . but I am not getting the transparency . How to get the transparency usnig gdi+
Rajesh
-
Graphics graphics(hdc);//Handle to the device context //Load the image from a file Image image(L"test.bmp",FALSE); // test.bmp is 32bit with alpha channels for transparency graphics.DrawImage(&image,0,0,image.GetWidth(),image.GetHeight());
Rajesh
-
You have to specify Colormatrix and load it via ImageAttributes' SetColorMatrix() before using DrawImage() Regards, Spk
-
Thats based upon your requirement... if you need to convert 80% of the bitmap alpha values use this sample one... ColorMatrix colorMatrix = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.8f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; ImageAttributes imageAtt; imageAtt.SetColorMatrix(&colorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap); Regards, Spk
-
Thats based upon your requirement... if you need to convert 80% of the bitmap alpha values use this sample one... ColorMatrix colorMatrix = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.8f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; ImageAttributes imageAtt; imageAtt.SetColorMatrix(&colorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap); Regards, Spk
-
I have a 32bit bitmap with alpha channnel . I am drawing it using gdi+ . but I am not getting the transparency . How to get the transparency usnig gdi+
Rajesh
If you call GetPixelFormat() on a 32-bit bitmap (.bmp) loaded with Image, it will return PixelFormat32bppRGB. I've found that using PNG images works.
-
If you call GetPixelFormat() on a 32-bit bitmap (.bmp) loaded with Image, it will return PixelFormat32bppRGB. I've found that using PNG images works.
-
It's exactly the same, just load a .PNG file that has an alpha channel.