1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-07-05 12:15:50 +03:00

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.
This commit is contained in:
kgv 2017-09-13 17:12:57 +02:00 committed by bugmaster
parent fae1ae1182
commit 7c4ce93bab

View File

@ -1795,8 +1795,8 @@ static Standard_Boolean SaveBitmap (HBITMAP theHBitmap,
} }
Image_AlienPixMap anImage; Image_AlienPixMap anImage;
const Standard_Size aSizeRowBytes = Standard_Size(aBitmap.bmWidth) * 4; const Standard_Size aSizeRowBytes = ((Standard_Size(aBitmap.bmWidth) * 24 + 31) / 32) * 4; // 4 bytes alignment for GetDIBits()
if (!anImage.InitTrash (Image_Format_BGR32, Standard_Size(aBitmap.bmWidth), Standard_Size(aBitmap.bmHeight), aSizeRowBytes)) if (!anImage.InitTrash (Image_Format_BGR, Standard_Size(aBitmap.bmWidth), Standard_Size(aBitmap.bmHeight), aSizeRowBytes))
{ {
return Standard_False; return Standard_False;
} }
@ -1809,7 +1809,7 @@ static Standard_Boolean SaveBitmap (HBITMAP theHBitmap,
aBitmapInfo.biWidth = aBitmap.bmWidth; aBitmapInfo.biWidth = aBitmap.bmWidth;
aBitmapInfo.biHeight = aBitmap.bmHeight; // positive means bottom-up! aBitmapInfo.biHeight = aBitmap.bmHeight; // positive means bottom-up!
aBitmapInfo.biPlanes = 1; aBitmapInfo.biPlanes = 1;
aBitmapInfo.biBitCount = 32; // use 32bit for automatic word-alignment per row aBitmapInfo.biBitCount = 24;
aBitmapInfo.biCompression = BI_RGB; aBitmapInfo.biCompression = BI_RGB;
// Copy the pixels // Copy the pixels