+wxBitmap wxBitmap::GetSubBitmap(
+ const wxRect& rRect
+) const
+{
+ wxCHECK_MSG( Ok() &&
+ (rRect.x >= 0) && (rRect.y >= 0) &&
+ (rRect.x + rRect.width <= GetWidth()) &&
+ (rRect.y + rRect.height <= GetHeight()),
+ wxNullBitmap, wxT("Invalid bitmap or bitmap region") );
+
+ wxBitmap vRet( rRect.width
+ ,rRect.height
+ ,GetDepth()
+ );
+ wxASSERT_MSG( vRet.Ok(), wxT("GetSubBitmap error") );
+
+
+ //
+ // Copy bitmap data
+ //
+ SIZEL vSize = {0, 0};
+ DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
+ HDC hDCSrc = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDop, NULLHANDLE);
+ HDC hDCDst = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDop, NULLHANDLE);
+ HPS hPSSrc = ::GpiCreatePS(vHabmain, hDCSrc, &vSize, PU_PELS | GPIA_ASSOC);
+ HPS hPSDst = ::GpiCreatePS(vHabmain, hDCDst, &vSize, PU_PELS | GPIA_ASSOC);
+ POINTL vPoint[4] = { {0, 0}, {rRect.width, rRect.height},
+ {rRect.x, rRect.y},
+ {rRect.x + rRect.width, rRect.y + rRect.height}
+ };
+
+ ::GpiSetBitmap(hPSSrc, (HBITMAP) GetHBITMAP());
+ ::GpiSetBitmap(hPSDst, (HBITMAP) vRet.GetHBITMAP());
+ ::GpiBitBlt( hPSDst
+ ,hPSSrc
+ ,4L
+ ,vPoint
+ ,ROP_SRCCOPY
+ ,BBO_IGNORE
+ );
+
+ //
+ // Copy mask if there is one
+ //
+ if (GetMask())
+ {
+ BITMAPINFOHEADER2 vBmih;
+
+ memset(&vBmih, '\0', sizeof(BITMAPINFOHEADER2));
+ vBmih.cbFix = sizeof(BITMAPINFOHEADER2);
+ vBmih.cx = rRect.width;
+ vBmih.cy = rRect.height;
+ vBmih.cPlanes = 1;
+ vBmih.cBitCount = 24;
+
+ HBITMAP hBmpMask = ::GpiCreateBitmap( hPSDst
+ ,&vBmih
+ ,0L
+ ,NULL
+ ,NULL
+ );
+
+ ::GpiSetBitmap(hPSSrc, (HBITMAP) GetHBITMAP());
+ ::GpiSetBitmap(hPSDst, (HBITMAP) vRet.GetHBITMAP());
+
+ ::GpiSetBitmap(hPSSrc, (HBITMAP) GetMask()->GetMaskBitmap());
+ ::GpiSetBitmap(hPSDst, (HBITMAP) hBmpMask);
+ ::GpiBitBlt( hPSDst
+ ,hPSSrc
+ ,4L
+ ,vPoint
+ ,ROP_SRCCOPY
+ ,BBO_IGNORE
+ );
+
+ wxMask* pMask = new wxMask((WXHBITMAP)hBmpMask);
+ vRet.SetMask(pMask);
+ }
+
+ ::GpiSetBitmap(hPSSrc, NULL);
+ ::GpiSetBitmap(hPSDst, NULL);
+ ::GpiDestroyPS(hPSSrc);
+ ::GpiDestroyPS(hPSDst);
+ ::DevCloseDC(hDCSrc);
+ ::DevCloseDC(hDCDst);
+ return vRet;
+} // end of wxBitmap::GetSubBitmap
+
+// ----------------------------------------------------------------------------
+// wxBitmap accessors
+// ----------------------------------------------------------------------------
+
+void wxBitmap::SetQuality(
+ int nQ
+)
+{
+ EnsureHasData();
+
+ GetBitmapData()->m_nQuality = nQ;
+} // end of wxBitmap::SetQuality
+
+void wxBitmap::SetPalette(
+ const wxPalette& rPalette
+)
+{
+ EnsureHasData();
+
+ GetBitmapData()->m_vBitmapPalette = rPalette;
+} // end of wxBitmap::SetPalette
+
+void wxBitmap::SetMask(
+ wxMask* pMask
+)
+{
+ EnsureHasData();
+
+ GetBitmapData()->m_pBitmapMask = pMask;
+} // end of wxBitmap::SetMask
+
+wxBitmap wxBitmap::GetBitmapForDC(wxDC& WXUNUSED(rDc)) const
+{
+ return(*this);
+} // end of wxBitmap::GetBitmapForDC