cairo_font_weight_t weight);
double m_size;
- bool m_underlined;
double m_red;
double m_green;
double m_blue;
cairo_font_face_t *m_font;
#elif defined(__WXGTK__)
PangoFontDescription* m_font;
+ bool m_underlined;
#endif
// These members are used when the font is created from its face name and
InitColour(col);
m_size = font.GetPointSize();
- m_underlined = font.GetUnderlined();
#ifdef __WXMAC__
m_font = cairo_quartz_font_face_create_for_cgfont( font.OSXGetCGFont() );
#elif defined(__WXGTK__)
m_font = pango_font_description_copy( font.GetNativeFontInfo()->description );
+ m_underlined = font.GetUnderlined();
#else
InitFontComponents
(
m_font = NULL;
#endif
- m_underlined = (flags & wxFONTFLAG_UNDERLINED) != 0;
+ // There is no need to set m_underlined under wxGTK in this case, it can
+ // only be used if m_font != NULL.
InitFontComponents
(
// 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...
- const cairo_format_t bufferFormat = bmp.GetDepth() == 32
+ cairo_format_t bufferFormat = bmp.GetDepth() == 32
#ifdef __WXGTK__
|| bmp.GetMask()
#endif
int stride = InitBuffer(bmp.GetWidth(), bmp.GetHeight(), bufferFormat);
- int bw = m_width;
- int bh = m_height;
wxBitmap bmpSource = bmp; // we need a non-const instance
wxUint32* data = (wxUint32*)m_buffer;
if ( bufferFormat == CAIRO_FORMAT_ARGB32 )
{
// use the bitmap's alpha
- wxAlphaPixelData pixData(bmpSource, wxPoint(0,0), wxSize(bw, bh));
+ wxAlphaPixelData
+ pixData(bmpSource, wxPoint(0, 0), wxSize(m_width, m_height));
wxCHECK_RET( pixData, wxT("Failed to gain raw access to bitmap data."));
wxAlphaPixelData::Iterator p(pixData);
- for (int y=0; y<bh; y++)
+ for (int y=0; y<m_height; y++)
{
wxAlphaPixelData::Iterator rowStart = p;
wxUint32* const rowStartDst = data;
- for (int x=0; x<bw; x++)
+ for (int x=0; x<m_width; x++)
{
// Each pixel in CAIRO_FORMAT_ARGB32 is a 32-bit quantity,
// with alpha in the upper 8 bits, then red, then green, then
}
else // no alpha
{
- wxNativePixelData pixData(bmpSource, wxPoint(0,0), wxSize(bw, bh));
+ wxNativePixelData
+ pixData(bmpSource, wxPoint(0, 0), wxSize(m_width, m_height));
wxCHECK_RET( pixData, wxT("Failed to gain raw access to bitmap data."));
wxNativePixelData::Iterator p(pixData);
- for (int y=0; y<bh; y++)
+ for (int y=0; y<m_height; y++)
{
wxNativePixelData::Iterator rowStart = p;
wxUint32* const rowStartDst = data;
- for (int x=0; x<bw; x++)
+ for (int x=0; x<m_width; x++)
{
// Each pixel in CAIRO_FORMAT_RGB24 is a 32-bit quantity, with
// the upper 8 bits unused. Red, Green, and Blue are stored in
wxBitmap bmpMask = bmpSource.GetMaskBitmap();
bufferFormat = CAIRO_FORMAT_ARGB32;
data = (wxUint32*)m_buffer;
- wxNativePixelData pixData(bmpMask, wxPoint(0,0), wxSize(bw, bh));
- wxCHECK_RET( pixData, wxT("Failed to gain raw access to mask bitmap data."));
+ wxNativePixelData
+ pixData(bmpMask, wxPoint(0, 0), wxSize(m_width, m_height));
+ wxCHECK_RET( pixData, wxT("Failed to gain raw access to mask data."));
wxNativePixelData::Iterator p(pixData);
- for (int y=0; y<bh; y++)
+ for (int y=0; y<m_height; y++)
{
wxNativePixelData::Iterator rowStart = p;
wxUint32* const rowStartDst = data;
- for (int x=0; x<bw; x++)
+ for (int x=0; x<m_width; x++)
{
if (p.Red()+p.Green()+p.Blue() == 0)
*data = 0;
delete [] m_buffer;
}
-// ----------------------------------------------------------------------------
-// wxGraphicsBitmap implementation
-// ----------------------------------------------------------------------------
-
-#if wxUSE_IMAGE
-
-wxImage wxGraphicsBitmap::ConvertToImage() const
-{
- const wxCairoBitmapData* const
- data = static_cast<wxCairoBitmapData*>(GetGraphicsData());
-
- return data ? data->ConvertToImage() : wxNullImage;
-}
-
-#endif // wxUSE_IMAGE
-
//-----------------------------------------------------------------------------
// wxCairoContext implementation
//-----------------------------------------------------------------------------
virtual wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap );
#if wxUSE_IMAGE
virtual wxGraphicsBitmap CreateBitmapFromImage(const wxImage& image);
+ virtual wxImage CreateImageFromBitmap(const wxGraphicsBitmap& bmp);
#endif // wxUSE_IMAGE
// create a graphics bitmap from a native bitmap
return bmp;
}
+wxImage wxCairoRenderer::CreateImageFromBitmap(const wxGraphicsBitmap& bmp)
+{
+ ENSURE_LOADED_OR_RETURN(wxNullImage);
+
+ const wxCairoBitmapData* const
+ data = static_cast<wxCairoBitmapData*>(bmp.GetGraphicsData());
+
+ return data ? data->ConvertToImage() : wxNullImage;
+}
+
#endif // wxUSE_IMAGE
+
wxGraphicsBitmap wxCairoRenderer::CreateBitmapFromNativeBitmap( void* bitmap )
{
ENSURE_LOADED_OR_RETURN(wxNullGraphicsBitmap);