]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/graphicc.cpp
Do not declare "environ" variable ourselves under MSW.
[wxWidgets.git] / src / generic / graphicc.cpp
index f203bdec3ca03cc1799ca897710cd3a49823520f..312cd846350ae768ae730d6022c0dbdf2c08f397 100644 (file)
@@ -1267,7 +1267,7 @@ wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitm
     // 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
@@ -1276,23 +1276,22 @@ wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitm
 
     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
@@ -1317,15 +1316,16 @@ wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitm
     }
     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
@@ -1349,15 +1349,16 @@ wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitm
         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;
@@ -1557,22 +1558,6 @@ wxCairoBitmapData::~wxCairoBitmapData()
     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
 //-----------------------------------------------------------------------------
@@ -2291,6 +2276,7 @@ public :
     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
@@ -2360,14 +2346,7 @@ wxGraphicsContext * wxCairoRenderer::CreateContext( const wxMemoryDC& dc)
 wxGraphicsContext * wxCairoRenderer::CreateContext( const wxPrinterDC& dc)
 {
     ENSURE_LOADED_OR_RETURN(NULL);
-#ifdef __WXGTK20__
-    const wxDCImpl *impl = dc.GetImpl();
-    cairo_t* context = (cairo_t*) impl->GetCairoContext();
-    if (context)
-       return new wxCairoContext(this,dc);
-    else
-#endif
-       return new wxCairoContext(this,dc);
+    return new wxCairoContext(this, dc);
 }
 
 #ifdef __WXMSW__
@@ -2557,8 +2536,19 @@ wxGraphicsBitmap wxCairoRenderer::CreateBitmapFromImage(const wxImage& image)
     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);