-
January 15th, 2014, 10:53 AM
#1
how to change a 24bit bitmap to a 32bit bitmap using GDI+
I mean 32bit to 24bit image.
Hi,
I have a bitmap file temp.bmp that is a 32bit image, now I want to resave it as 24bit image but for some reason the code below is still saving it as a 32bit image (temp2.bmp) even though 24bit has been specified as the colorDepth.
Any ideas? do I need to re-render it first? if so, how?
Status stat;
Image* image = new Image(_T("temp.bmp"));
Gdiplus::EncoderParameters EncoderParameters1;
ULONG colorDeph = 24;
EncoderParameters1.Count = 1;
EncoderParameters1.Parameter[0].Guid = EncoderColorDepth;
EncoderParameters1.Parameter[0].Type = EncoderParameterValueTypeLong;
EncoderParameters1.Parameter[0].NumberOfValues = 1;
EncoderParameters1.Parameter[0].Value = &colorDeph;
CLSID m_clsidGdiplusBmpEncoder;
GetEncoderClsid( L"image/bmp", &m_clsidGdiplusBmpEncoder );
stat = image->Save( _T("temp2.bmp"), &m_clsidGdiplusBmpEncoder, &EncoderParameters1 );
Thanks,
Hobnob
Last edited by hobnob; January 16th, 2014 at 08:31 AM.
-
January 16th, 2014, 09:10 AM
#2
Re: how to change a 24bit bitmap to a 32bit bitmap using GDI+
worked it out, draw it in memory to 24bit then save.
Image* image = new Image(L"temp.bmp"); // 32bit image
Bitmap *dest = new Bitmap(image->GetWidth(), image->GetHeight(), PixelFormat24bppRGB);
//create a graphics from the image
Graphics *g = Graphics::FromImage(dest);
//draw the 32bit per pixel image into the 24 bit per pixel image
g->DrawImage(image, Point(0, 0));
delete image; // source
//now save the 24 bit per pixel to disk
CLSID m_clsidGdiplusBmpEncoder;
GetEncoderClsid( L"image/bmp", &m_clsidGdiplusBmpEncoder );
dest->Save( L"temp2.bmp", &m_clsidGdiplusBmpEncoder, NULL );
delete dest;
delete g;
-
January 16th, 2014, 09:41 AM
#3
Re: how to change a 24bit bitmap to a 32bit bitmap using GDI+
the GDI plus bmp encoder doesn't support 24bpp. (I'm not entirely sure, but I even think it doesn't even support this parameter at all).
this is similar to trying to set a JPEG encoder to 32bpp (or something other than 24), JPEG doesn't support an alpha channel, so encoding is Always 24bpp
-
February 14th, 2014, 08:40 AM
#4
Re: how to change a 24bit bitmap to a 32bit bitmap using GDI+
I tend to join to your opinion. I haven't heard about such support.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|