+wxBitmap::wxBitmap(const wxString &filename, wxBitmapType type)
+{
+ LoadFile(filename, type);
+}
+
+wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
+{
+ wxASSERT(depth == 1);
+ if (width > 0 && height > 0 && depth == 1)
+ {
+ m_refData = new wxBitmapRefData(width, height, 1);
+#ifdef __WXGTK3__
+ GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, width, height);
+ M_BMPDATA->m_pixbufNoMask = pixbuf;
+ const char* src = bits;
+ guchar* dst = gdk_pixbuf_get_pixels(pixbuf);
+ const int stride_src = (width + 7) / 8;
+ const int rowinc_dst = gdk_pixbuf_get_rowstride(pixbuf) - 3 * width;
+ for (int j = 0; j < width; j++, src += stride_src, dst += rowinc_dst)
+ {
+ for (int i = 0; i < height; i++)
+ {
+ guchar c = 0xff;
+ if (src[i >> 3] & (1 << (i & 7)))
+ c = 0;
+ *dst++ = c;
+ *dst++ = c;
+ *dst++ = c;
+ }
+ }
+#else
+ M_BMPDATA->m_pixmap = gdk_bitmap_create_from_data(
+ wxGetRootWindow()->window, bits, width, height);
+#endif
+ }
+}
+
+wxBitmap::wxBitmap(const char* const* bits)
+{
+ wxCHECK2_MSG(bits != NULL, return, wxT("invalid bitmap data"));
+
+#if wxUSE_IMAGE
+ *this = wxBitmap(wxImage(bits));
+#elif defined __WXGTK3__
+ GdkPixbuf* pixbuf = gdk_pixbuf_new_from_xpm_data(const_cast<const char**>(bits));
+ if (pixbuf)
+ {
+ m_refData = new wxBitmapRefData(
+ gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf),
+ gdk_pixbuf_get_n_channels(pixbuf) * 8);
+ M_BMPDATA->m_pixbufNoMask = pixbuf;
+ wxASSERT(M_BMPDATA->m_bpp == 32 || !gdk_pixbuf_get_has_alpha(M_BMPDATA->m_pixbufNoMask));
+ }
+#else
+ GdkBitmap* mask = NULL;
+ GdkPixmap* pixmap = gdk_pixmap_create_from_xpm_d(wxGetRootWindow()->window, &mask, NULL, const_cast<char**>(bits));
+ if (pixmap)
+ {
+ int width, height;
+ gdk_drawable_get_size(pixmap, &width, &height);
+ m_refData = new wxBitmapRefData(width, height, -1);
+ M_BMPDATA->m_pixmap = pixmap;
+ if (mask)
+ {
+ M_BMPDATA->m_mask = new wxMask(mask);
+ }
+ }
+#endif
+}
+
+wxBitmap::wxBitmap(GdkPixbuf* pixbuf)
+{
+ if (pixbuf)
+ {
+ wxBitmapRefData* bmpData = new wxBitmapRefData(
+ gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf),
+ gdk_pixbuf_get_n_channels(pixbuf) * 8);
+ m_refData = bmpData;
+#ifdef __WXGTK3__
+ bmpData->m_pixbufNoMask = pixbuf;
+#else
+ bmpData->m_pixbuf = pixbuf;
+#endif
+ }
+}
+
+wxBitmap::~wxBitmap()