开发者

Setting the pixel format of an existing Bitmap in GDI+

开发者 https://www.devze.com 2022-12-29 19:00 出处:网络
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.I e

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.


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));
0

精彩评论

暂无评论...
验证码 换一张
取 消