Fix to allow using Cairo version < 1.2 where
cairo_image_surface_get_data doesn't exist. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@44597 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1152,12 +1152,16 @@ void wxCairoContext::DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wx
|
|||||||
int bw = bmp.GetWidth();
|
int bw = bmp.GetWidth();
|
||||||
int bh = bmp.GetHeight();
|
int bh = bmp.GetHeight();
|
||||||
wxBitmap bmpSource = bmp; // we need a non-const instance
|
wxBitmap bmpSource = bmp; // we need a non-const instance
|
||||||
|
unsigned char* buffer = new unsigned char[bw*bh*4];
|
||||||
|
wxUint32* data = (wxUint32*)buffer;
|
||||||
|
|
||||||
// Create a surface object and copy the bitmap pixel data to it.
|
// Create a surface object and copy the bitmap pixel data to it. if the
|
||||||
|
// image has alpha (or a mask represented as alpha) then we'll use a
|
||||||
|
// different format and iterator than if it doesn't...
|
||||||
if (bmpSource.HasAlpha() || bmpSource.GetMask())
|
if (bmpSource.HasAlpha() || bmpSource.GetMask())
|
||||||
{
|
{
|
||||||
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, bw, bh);
|
surface = cairo_image_surface_create_for_data(
|
||||||
wxUint32* data = (wxUint32*)cairo_image_surface_get_data(surface);
|
buffer, CAIRO_FORMAT_ARGB32, bw, bh, bw*4);
|
||||||
wxAlphaPixelData pixData(bmpSource, wxPoint(0,0), wxSize(bw, bh));
|
wxAlphaPixelData pixData(bmpSource, wxPoint(0,0), wxSize(bw, bh));
|
||||||
wxCHECK_RET( pixData, wxT("Failed to gain raw access to bitmap data."));
|
wxCHECK_RET( pixData, wxT("Failed to gain raw access to bitmap data."));
|
||||||
|
|
||||||
@@ -1186,14 +1190,10 @@ void wxCairoContext::DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wx
|
|||||||
p.OffsetY(pixData, 1);
|
p.OffsetY(pixData, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else // no alpha
|
||||||
{
|
{
|
||||||
wxImage img = bmpSource.ConvertToImage();
|
|
||||||
surface = cairo_image_surface_create_for_data(
|
surface = cairo_image_surface_create_for_data(
|
||||||
img.GetData(), CAIRO_FORMAT_RGB24, bw, bh, bw*3);
|
buffer, CAIRO_FORMAT_RGB24, bw, bh, bw*4);
|
||||||
|
|
||||||
surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, bw, bh);
|
|
||||||
wxUint32* data = (wxUint32*)cairo_image_surface_get_data(surface);
|
|
||||||
wxNativePixelData pixData(bmpSource, wxPoint(0,0), wxSize(bw, bh));
|
wxNativePixelData pixData(bmpSource, wxPoint(0,0), wxSize(bw, bh));
|
||||||
wxCHECK_RET( pixData, wxT("Failed to gain raw access to bitmap data."));
|
wxCHECK_RET( pixData, wxT("Failed to gain raw access to bitmap data."));
|
||||||
|
|
||||||
@@ -1238,6 +1238,7 @@ void wxCairoContext::DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wx
|
|||||||
// clean up
|
// clean up
|
||||||
cairo_pattern_destroy(pattern);
|
cairo_pattern_destroy(pattern);
|
||||||
cairo_surface_destroy(surface);
|
cairo_surface_destroy(surface);
|
||||||
|
delete [] buffer;
|
||||||
PopState();
|
PopState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user