X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b1b054dad6ca9a0407f4fc2c6c87763a7dfe3888..7ee31b00ed1aff56aa22f43f65a8604f6937ca37:/src/os2/bitmap.cpp?ds=inline diff --git a/src/os2/bitmap.cpp b/src/os2/bitmap.cpp index 99264e0611..94dcdeaa5d 100644 --- a/src/os2/bitmap.cpp +++ b/src/os2/bitmap.cpp @@ -227,6 +227,8 @@ wxBitmap::wxBitmap( pzData = (char *)zBits; // const_cast is harmless } + if (nDepth > 24) + nDepth = 24; // MAX supported in PM memset(&vHeader, '\0', 16); vHeader.cbFix = 16; vHeader.cx = (USHORT)nWidth; @@ -346,6 +348,9 @@ bool wxBitmap::Create( hDCScreen = ::GpiQueryDevice(hPSScreen); ::DevQueryCaps(hDCScreen, CAPS_COLOR_BITCOUNT, 1L, &lBitCount); + if (lBitCount > 24) + lBitCount = 24; + memset(&vHeader, '\0', 16); vHeader.cbFix = 16; vHeader.cx = nW; @@ -574,12 +579,6 @@ bool wxBitmap::CreateFromImage ( vHeader.cPlanes = 1L; vHeader.cBitCount = 24; - memset(&vInfo, '\0', 16); - vInfo.cbFix = 16; - vInfo.cx = (ULONG)nWidth; - vInfo.cy = (ULONG)nHeight; - vInfo.cPlanes = 1L; - vInfo.cBitCount = 24; // // Memory for DIB data // @@ -591,6 +590,7 @@ bool wxBitmap::CreateFromImage ( wxFAIL_MSG(wxT("could not allocate memory for DIB")); return FALSE; } + memset(pucBits, '\0', (nBytePerLine * nHeight)); // // Create and set the device-dependent bitmap @@ -605,6 +605,13 @@ bool wxBitmap::CreateFromImage ( HBITMAP hBmp; HBITMAP hBmpOld; + memset(&vInfo, '\0', 16); + vInfo.cbFix = 16; + vInfo.cx = (ULONG)nWidth; + vInfo.cy = (ULONG)nHeight; + vInfo.cPlanes = 1; + vInfo.cBitCount = 24; // Set to desired count going in + hBmp = ::GpiCreateBitmap( hPS ,&vHeader ,0L @@ -661,7 +668,6 @@ bool wxBitmap::CreateFromImage ( // Have to do something similar to WIN32's StretchDIBits, use GpiBitBlt // in combination with setting the bits into the selected bitmap // - vInfo.cBitCount = 16; if ((lScans = ::GpiSetBitmapBits( hPS ,0 // Start at the bottom ,(LONG)nHeight // One line per scan @@ -675,25 +681,9 @@ bool wxBitmap::CreateFromImage ( vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); } - // - // for debugging---- + // Debug stuff // -LONG alFormats[24]; -::GpiQueryDeviceBitmapFormats(hPS, 24, alFormats); -if ((lScans = ::GpiQueryBitmapBits( hPS - ,0L - ,(LONG)nHeight - ,(PBYTE)pucBits - ,&vInfo - )) == GPI_ALTERROR) -{ - ERRORID vError; - wxString sError; - - vError = ::WinGetLastError(vHabmain); - sError = wxPMErrorToStr(vError); -} hPSScreen = ::GpiCreatePS( vHabmain ,hDCScreen @@ -827,6 +817,7 @@ if ((lScans = ::GpiQueryBitmapBits( hPS // ::GpiSetBitmap(hPS, NULLHANDLE); ::GpiDestroyPS(hPS); + ::DevCloseDC(hDCScreen); ::DevCloseDC(hDC); free(pucBits); return TRUE; @@ -904,6 +895,8 @@ wxImage wxBitmap::ConvertToImage() const free(pData); return wxNullImage; } + memset(lpBits, '\0', (nBytePerLine * nHeight)); + hBitmap = (HBITMAP)GetHBITMAP(); // // May already be selected into a PS @@ -926,7 +919,6 @@ wxImage wxBitmap::ConvertToImage() const ,&vSizlPage ,PU_PELS | GPIA_ASSOC ); - hBitmap = (HBITMAP)GetHBITMAP(); if ((hOldBitmap = ::GpiSetBitmap(hPSMem, hBitmap)) == HBM_ERROR) { ERRORID vError;