+#if wxUSE_IMAGE
+
+wxGraphicsBitmap wxGDIPlusRenderer::CreateBitmapFromImage(const wxImage& image)
+{
+ ENSURE_LOADED_OR_RETURN(wxNullGraphicsBitmap);
+ if ( image.IsOk() )
+ {
+ // Notice that we rely on conversion from wxImage to wxBitmap here but
+ // we could probably do it more efficiently by converting from wxImage
+ // to GDI+ Bitmap directly, i.e. copying wxImage pixels to the buffer
+ // returned by Bitmap::LockBits(). However this would require writing
+ // code specific for this task while like this we can reuse existing
+ // code (see also wxGDIPlusBitmapData::ConvertToImage()).
+ wxGraphicsBitmap gb;
+ gb.SetRefData(new wxGDIPlusBitmapData(this, image));
+ return gb;
+ }
+ else
+ return wxNullGraphicsBitmap;
+}
+
+
+wxImage wxGDIPlusRenderer::CreateImageFromBitmap(const wxGraphicsBitmap& bmp)
+{
+ ENSURE_LOADED_OR_RETURN(wxNullImage);
+ const wxGDIPlusBitmapData* const
+ data = static_cast<wxGDIPlusBitmapData*>(bmp.GetGraphicsData());
+
+ return data ? data->ConvertToImage() : wxNullImage;
+}
+
+#endif // wxUSE_IMAGE
+
+