+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ }
+ for (n = 0; n < nNumDIB; n++)
+ {
+ if (nNumDIB > 1 && n == nNumDIB - 1 && nHRemain > 0)
+ {
+ //
+ // Redefine height and size of the (possibly) last smaller DIB
+ // memory is not reallocated
+ //
+ nHeight = nHRemain;
+ vHeader.cy = (DWORD)(nHeight);
+ vHeader.cbImage = nBytePerLine * nHeight;
+ }
+ ptbits = pucBits;
+ for (j = 0; j < nHeight; j++)
+ {
+ for (i = 0; i < nWidth; i++)
+ {
+ *(ptbits++) = *(ptdata + 2);
+ *(ptbits++) = *(ptdata + 1);
+ *(ptbits++) = *(ptdata);
+ ptdata += 3;
+ }
+ for (i = 0; i < nPadding; i++)
+ *(ptbits++) = 0;
+ }
+
+ //
+ // Have to do something similar to WIN32's StretchDIBits, use GpiBitBlt
+ // in combination with setting the bits into the selected bitmap
+ //
+ if ((lScans = ::GpiSetBitmapBits( hPS
+ ,0 // Start at the bottom
+ ,(LONG)nHeight // One line per scan
+ ,(PBYTE)pucBits
+ ,&vInfo
+ )) == GPI_ALTERROR)
+ {
+ ERRORID vError;
+ wxString sError;
+
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ }
+ hPSScreen = ::GpiCreatePS( vHabmain
+ ,hDCScreen
+ ,&vSize
+ ,PU_PELS | GPIA_ASSOC
+ );
+
+ POINTL vPoint[4] = { 0, nOrigin,
+ nWidth, nHeight,
+ 0, 0, nWidth, nHeight
+ };
+
+
+ ::GpiBitBlt( hPSScreen
+ ,hPS
+ ,4
+ ,vPoint
+ ,ROP_SRCCOPY
+ ,BBO_IGNORE
+ );
+ ::GpiDestroyPS(hPSScreen);
+ nOrigin += nHeight;
+ }
+ SetHBITMAP((WXHBITMAP)hBmp);
+#if wxUSE_PALETTE
+ if (hOldPalette)
+ ::GpiSelectPalette(hPS, hOldPalette);
+#endif // wxUSE_PALETTE
+
+ //
+ // Similarly, created an mono-bitmap for the possible mask
+ //
+ if (rImage.HasMask())
+ {
+ vHeader.cbFix = 16;
+ vHeader.cx = nWidth;
+ vHeader.cy = nHeight;
+ vHeader.cPlanes = 1;
+ vHeader.cBitCount = 24;
+ hBmp = ::GpiCreateBitmap( hPS
+ ,&vHeader
+ ,0L
+ ,NULL
+ ,NULL
+ );
+ hBmpOld = ::GpiSetBitmap(hPS, hBmp);
+ if (nNumDIB == 1)
+ nHeight = nBmpHeight;
+ else
+ nHeight = nSizeLimit / nBytePerLine;
+ vHeader.cy = (DWORD)(nHeight);
+ nOrigin = 0;
+
+ unsigned char cRed = rImage.GetMaskRed();
+ unsigned char cGreen = rImage.GetMaskGreen();
+ unsigned char cBlue = rImage.GetMaskBlue();
+ unsigned char cZero = 0;
+ unsigned char cOne = 255;
+
+ ptdata = pData;
+ for (n = 0; n < nNumDIB; n++)
+ {
+ if (nNumDIB > 1 && n == nNumDIB - 1 && nHRemain > 0)
+ {
+ //
+ // Redefine height and size of the (possibly) last smaller DIB
+ // memory is not reallocated
+ //
+ nHeight = nHRemain;
+ vHeader.cy = (DWORD)(nHeight);
+ vHeader.cbImage = nBytePerLine * nHeight;
+ }
+ ptbits = pucBits;
+ for (int j = 0; j < nHeight; j++)
+ {
+ for (i = 0; i < nWidth; i++)
+ {
+ unsigned char cRedImage = (*(ptdata++)) ;
+ unsigned char cGreenImage = (*(ptdata++)) ;
+ unsigned char cBlueImage = (*(ptdata++)) ;
+
+ if ((cRedImage != cRed) || (cGreenImage != cGreen) || (cBlueImage != cBlue))
+ {
+ *(ptbits++) = cOne;
+ *(ptbits++) = cOne;
+ *(ptbits++) = cOne;
+ }
+ else
+ {
+ *(ptbits++) = cZero;
+ *(ptbits++) = cZero;
+ *(ptbits++) = cZero;
+ }
+ }
+ for (i = 0; i < nPadding; i++)
+ *(ptbits++) = cZero;
+ }
+ lScans = ::GpiSetBitmapBits( hPS
+ ,0 // Start at the bottom
+ ,(LONG)nHeight // One line per scan
+ ,(PBYTE)pucBits
+ ,&vInfo
+ );
+ hPSScreen = ::GpiCreatePS( vHabmain
+ ,hDCScreen
+ ,&vSize
+ ,PU_PELS | GPIA_ASSOC
+ );
+ POINTL vPoint2[4] = { 0, nOrigin,
+ nWidth, nHeight,
+ 0, 0, nWidth, nHeight
+ };
+ ::GpiBitBlt( hPSScreen
+ ,hPS
+ ,4
+ ,vPoint2
+ ,ROP_SRCCOPY
+ ,BBO_IGNORE
+ );
+ ::GpiDestroyPS(hPSScreen);
+ nOrigin += nHeight;
+ }
+
+ //
+ // Create a wxMask object
+ //
+ wxMask* pMask = new wxMask();
+
+ pMask->SetMaskBitmap((WXHBITMAP)hBmp);
+ SetMask(pMask);
+ hBmpOld = ::GpiSetBitmap(hPS, hBmpOld);
+ }