Backport MSW wxGraphicsBitmap fixes from trunk.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@56880 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Kevin Ollivier
2008-11-21 04:46:57 +00:00
parent aa398e1d3a
commit c41168ca31

View File

@@ -269,6 +269,7 @@ public:
private : private :
Bitmap* m_bitmap; Bitmap* m_bitmap;
Bitmap* m_helper;
}; };
class WXDLLIMPEXP_CORE wxGDIPlusFontData : public wxGraphicsObjectRefData class WXDLLIMPEXP_CORE wxGDIPlusFontData : public wxGraphicsObjectRefData
@@ -630,8 +631,8 @@ wxGDIPlusBitmapData::wxGDIPlusBitmapData( wxGraphicsRenderer* renderer,
const wxBitmap &bmp) : wxGraphicsObjectRefData( renderer ) const wxBitmap &bmp) : wxGraphicsObjectRefData( renderer )
{ {
m_bitmap = NULL; m_bitmap = NULL;
m_helper = NULL;
Bitmap* image = NULL; Bitmap* image = NULL;
Bitmap* helper = NULL;
if ( bmp.GetMask() ) if ( bmp.GetMask() )
{ {
Bitmap interim((HBITMAP)bmp.GetHBITMAP(),(HPALETTE)bmp.GetPalette()->GetHPALETTE()) ; Bitmap interim((HBITMAP)bmp.GetHBITMAP(),(HPALETTE)bmp.GetPalette()->GetHPALETTE()) ;
@@ -696,27 +697,27 @@ wxGDIPlusBitmapData::wxGDIPlusBitmapData( wxGraphicsRenderer* renderer,
size_t width = image->GetWidth(); size_t width = image->GetWidth();
size_t height = image->GetHeight(); size_t height = image->GetHeight();
Rect bounds(0,0,width,height); Rect bounds(0,0,width,height);
BitmapData data ; static BitmapData data ;
helper = image ; m_helper = image ;
image = NULL ; image = NULL ;
helper->LockBits(&bounds, ImageLockModeRead, m_helper->LockBits(&bounds, ImageLockModeRead,
helper->GetPixelFormat(),&data); m_helper->GetPixelFormat(),&data);
image = new Bitmap(data.Width, data.Height, data.Stride, image = new Bitmap(data.Width, data.Height, data.Stride,
PixelFormat32bppPARGB , (BYTE*) data.Scan0); PixelFormat32bppPARGB , (BYTE*) data.Scan0);
helper->UnlockBits(&data); m_helper->UnlockBits(&data);
} }
} }
if ( image ) if ( image )
m_bitmap = image; m_bitmap = image;
delete helper;
} }
wxGDIPlusBitmapData::~wxGDIPlusBitmapData() wxGDIPlusBitmapData::~wxGDIPlusBitmapData()
{ {
delete m_bitmap; delete m_bitmap;
delete m_helper;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -1180,7 +1181,17 @@ void wxGDIPlusContext::DrawGraphicsBitmapInternal( const wxGraphicsBitmap &bmp,
{ {
Bitmap* image = static_cast<wxGDIPlusBitmapData*>(bmp.GetRefData())->GetGDIPlusBitmap(); Bitmap* image = static_cast<wxGDIPlusBitmapData*>(bmp.GetRefData())->GetGDIPlusBitmap();
if ( image ) if ( image )
m_context->DrawImage(image,(REAL) x,(REAL) y,(REAL) w,(REAL) h) ; {
if( image->GetWidth() != (UINT) w || image->GetHeight() != (UINT) h )
{
Rect drawRect((REAL) x, (REAL)y, (REAL)w, (REAL)h);
m_context->SetPixelOffsetMode( PixelOffsetModeNone );
m_context->DrawImage(image, drawRect, 0 , 0 , image->GetWidth()-1, image->GetHeight()-1, UnitPixel ) ;
m_context->SetPixelOffsetMode( PixelOffsetModeHalf );
}
else
m_context->DrawImage(image,(REAL) x,(REAL) y,(REAL) w,(REAL) h) ;
}
} }
void wxGDIPlusContext::DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) void wxGDIPlusContext::DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h )