tags:

views:

90

answers:

1

How do I set the PixelFormat property in a GDI+ Bitmap if I can't use one of the constructors that allow me to specify it? It looks like the PixelFormat property itself is read-only.

+1  A: 

I ended up using the following method of creating a second bitmap with the desired pixel format and drawing the original image on to it.

Bitmap *pTempBitmap = new Gdiplus::Bitmap(_Module.m_hInst, MAKEINTRESOURCE(lImageResource));
m_pGDIBitmap = new Bitmap(pTempBitmap->GetWidth(), pTempBitmap->GetHeight(), PixelFormat32bppARGB);
Graphics TempGraphics(pTempBitmap);
TempGraphics.DrawImage(m_pGDIBitmap, Point(0,0));
dlanod