-#ifdef __WXGTK20__
-bool wxBitmap::CreateFromImageAsPixbuf(const wxImage& image)
-{
- int width = image.GetWidth();
- int height = image.GetHeight();
-
- GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
- image.HasAlpha(),
- 8 /* bits per sample */,
- width, height);
- if (!pixbuf)
- return false;
-
- wxASSERT( gdk_pixbuf_get_n_channels(pixbuf) == 4 );
- wxASSERT( gdk_pixbuf_get_width(pixbuf) == width );
- wxASSERT( gdk_pixbuf_get_height(pixbuf) == height );
-
- M_BMPDATA->m_pixbuf = pixbuf;
- SetHeight(height);
- SetWidth(width);
- SetDepth(wxTheApp->GetGdkVisual()->depth);
-
- // Copy the data:
- unsigned char *in = image.GetData();
- unsigned char *out = gdk_pixbuf_get_pixels(pixbuf);
- unsigned char *alpha = image.GetAlpha();
-
- int rowinc = gdk_pixbuf_get_rowstride(pixbuf) - 4 * width;
-
-
- for (int y = 0; y < height; y++, out += rowinc)
- {
- for (int x = 0; x < width; x++, alpha++, out += 4, in += 3)
- {
- out[0] = in[0];
- out[1] = in[1];
- out[2] = in[2];
- out[3] = *alpha;
- }
- }
-
- return true;
-}
-#endif // __WXGTK20__
-