(Port to 2.8) Fix for wxMemoryDC::GetAsBitmap(wxRect) on Windows.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@48236 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -105,6 +105,10 @@ public:
|
|||||||
// get the given part of bitmap
|
// get the given part of bitmap
|
||||||
wxBitmap GetSubBitmap( const wxRect& rect ) const;
|
wxBitmap GetSubBitmap( const wxRect& rect ) const;
|
||||||
|
|
||||||
|
// NB: This should not be called from user code. It is for wx internal
|
||||||
|
// use only.
|
||||||
|
wxBitmap GetSubBitmapOfHDC( const wxRect& rect, WXHDC hdc ) const;
|
||||||
|
|
||||||
// copies the contents and mask of the given (colour) icon to the bitmap
|
// copies the contents and mask of the given (colour) icon to the bitmap
|
||||||
bool CopyFromIcon(const wxIcon& icon);
|
bool CopyFromIcon(const wxIcon& icon);
|
||||||
|
|
||||||
|
@@ -28,6 +28,9 @@ protected:
|
|||||||
virtual void DoGetSize(int* width, int* height) const;
|
virtual void DoGetSize(int* width, int* height) const;
|
||||||
virtual void DoSelect(const wxBitmap& bitmap);
|
virtual void DoSelect(const wxBitmap& bitmap);
|
||||||
|
|
||||||
|
virtual wxBitmap DoGetAsBitmap(const wxRect* subrect) const
|
||||||
|
{ return subrect == NULL ? GetSelectedBitmap() : GetSelectedBitmap().GetSubBitmapOfHDC(*subrect, GetHDC() );}
|
||||||
|
|
||||||
// create DC compatible with the given one or screen if dc == NULL
|
// create DC compatible with the given one or screen if dc == NULL
|
||||||
bool CreateCompatible(wxDC *dc);
|
bool CreateCompatible(wxDC *dc);
|
||||||
|
|
||||||
|
@@ -1070,8 +1070,14 @@ bool wxBitmap::SaveFile(const wxString& filename,
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// sub bitmap extraction
|
// sub bitmap extraction
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect ) const
|
||||||
|
{
|
||||||
|
MemoryHDC dcSrc;
|
||||||
|
SelectInHDC selectSrc(dcSrc, GetHbitmap());
|
||||||
|
return GetSubBitmapOfHDC( rect, (WXHDC)dcSrc );
|
||||||
|
}
|
||||||
|
|
||||||
wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
|
wxBitmap wxBitmap::GetSubBitmapOfHDC( const wxRect& rect, WXHDC hdc ) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok() &&
|
wxCHECK_MSG( Ok() &&
|
||||||
(rect.x >= 0) && (rect.y >= 0) &&
|
(rect.x >= 0) && (rect.y >= 0) &&
|
||||||
@@ -1092,16 +1098,15 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
|
|||||||
dcDst;
|
dcDst;
|
||||||
|
|
||||||
{
|
{
|
||||||
SelectInHDC selectSrc(dcSrc, GetHbitmap()),
|
SelectInHDC selectDst(dcDst, GetHbitmapOf(ret));
|
||||||
selectDst(dcDst, GetHbitmapOf(ret));
|
|
||||||
|
if ( !selectDst )
|
||||||
if ( !selectSrc || !selectDst )
|
|
||||||
{
|
{
|
||||||
wxLogLastError(_T("SelectObjct(hBitmap)"));
|
wxLogLastError(_T("SelectObject(destBitmap)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !::BitBlt(dcDst, 0, 0, rect.width, rect.height,
|
if ( !::BitBlt(dcDst, 0, 0, rect.width, rect.height,
|
||||||
dcSrc, rect.x, rect.y, SRCCOPY) )
|
(HDC)hdc, rect.x, rect.y, SRCCOPY) )
|
||||||
{
|
{
|
||||||
wxLogLastError(_T("BitBlt"));
|
wxLogLastError(_T("BitBlt"));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user