From: kgv Date: Wed, 13 Sep 2017 15:12:57 +0000 (+0200) Subject: 0029184: Visualization - DrawWindow::Save() fails when using WinCodec with PNG codec X-Git-Tag: V7_3_0_beta~228 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=7c4ce93bab44675c681f59fbb39db24e202a16dc;p=occt.git 0029184: Visualization - DrawWindow::Save() fails when using WinCodec with PNG codec DrawWindow::Save() now uses Image_Format_BGR instead of Image_Format_BGR32 for better compatibility with image encoders when dumping WinAPI bitmap. --- diff --git a/src/Draw/Draw_Window.cxx b/src/Draw/Draw_Window.cxx index 2d9f799bed..2fac12bc88 100644 --- a/src/Draw/Draw_Window.cxx +++ b/src/Draw/Draw_Window.cxx @@ -1795,8 +1795,8 @@ static Standard_Boolean SaveBitmap (HBITMAP theHBitmap, } Image_AlienPixMap anImage; - const Standard_Size aSizeRowBytes = Standard_Size(aBitmap.bmWidth) * 4; - if (!anImage.InitTrash (Image_Format_BGR32, Standard_Size(aBitmap.bmWidth), Standard_Size(aBitmap.bmHeight), aSizeRowBytes)) + const Standard_Size aSizeRowBytes = ((Standard_Size(aBitmap.bmWidth) * 24 + 31) / 32) * 4; // 4 bytes alignment for GetDIBits() + if (!anImage.InitTrash (Image_Format_BGR, Standard_Size(aBitmap.bmWidth), Standard_Size(aBitmap.bmHeight), aSizeRowBytes)) { return Standard_False; } @@ -1809,7 +1809,7 @@ static Standard_Boolean SaveBitmap (HBITMAP theHBitmap, aBitmapInfo.biWidth = aBitmap.bmWidth; aBitmapInfo.biHeight = aBitmap.bmHeight; // positive means bottom-up! aBitmapInfo.biPlanes = 1; - aBitmapInfo.biBitCount = 32; // use 32bit for automatic word-alignment per row + aBitmapInfo.biBitCount = 24; aBitmapInfo.biCompression = BI_RGB; // Copy the pixels