wxBitmap( const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH )
{ (void)CreateFromImage(image, depth); }
#endif // wxUSE_IMAGE
+ wxBitmap(GdkPixbuf* pixbuf);
virtual ~wxBitmap();
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
void SetHeight( int height );
void SetWidth( int width );
void SetDepth( int depth );
- void SetPixbuf(GdkPixbuf* pixbuf);
GdkPixmap *GetPixmap() const;
bool HasPixmap() const;
// Author: Jens Lody and Teodor Petrov
// Modified by:
// Created: 2012-03-23
-// RCS-ID: $Id:$
+// RCS-ID: $Id$
// Copyright: (c) 2012 Jens Lody <jens@codeblocks.org>
// and Teodor Petrov
// Licence: wxWindows licence
int xthickness = style_button->xthickness;
int ythickness = style_button->ythickness;
- wxBitmap bmp;
- bmp.SetPixbuf(gtk_widget_render_icon(widget, GTK_STOCK_CLOSE, GTK_ICON_SIZE_SMALL_TOOLBAR, "tab"));
+ wxBitmap bmp(gtk_widget_render_icon(widget, GTK_STOCK_CLOSE, GTK_ICON_SIZE_SMALL_TOOLBAR, "tab"));
if(bmp.GetWidth() != s_CloseIconSize || bmp.GetHeight() != s_CloseIconSize)
{
continue;
wxIcon icon;
- icon.SetPixbuf(pixbuf);
+ icon.CopyFromBitmap(wxBitmap(pixbuf));
bundle.AddIcon(icon);
}
}
}
- wxBitmap bmp;
- if (pixbuf != NULL)
- bmp.SetPixbuf(pixbuf);
-
- return bmp;
+ return wxBitmap(pixbuf);
}
wxIconBundle
}
}
+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;
+ bmpData->m_pixbuf = pixbuf;
+ }
+}
+
wxBitmap::~wxBitmap()
{
}
{
wxUnusedVar(type); // The type is detected automatically by GDK.
- UnRef();
- GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(name.fn_str(), NULL);
- if (pixbuf)
- SetPixbuf(pixbuf);
+ *this = wxBitmap(gdk_pixbuf_new_from_file(name.fn_str(), NULL));
}
return IsOk();
return M_BMPDATA->m_pixbuf != NULL;
}
-void wxBitmap::SetPixbuf(GdkPixbuf* pixbuf)
-{
- UnRef();
-
- if (!pixbuf)
- return;
-
- int depth = -1;
- if (gdk_pixbuf_get_has_alpha(pixbuf))
- depth = 32;
- m_refData = new wxBitmapRefData(
- gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf), depth);
-
- M_BMPDATA->m_pixbuf = pixbuf;
-}
-
void wxBitmap::PurgeOtherRepresentations(wxBitmap::Representation keep)
{
if (keep == Pixmap && HasPixbuf())
if ( pixbuf )
{
g_object_ref( pixbuf );
- bitmap.SetPixbuf( pixbuf );
+ bitmap = wxBitmap(pixbuf);
}
g_value_unset( &value );
}