// wxBitmap
//-----------------------------------------------------------------------------
-class wxBitmapRefData: public wxObjectRefData
+class wxBitmapRefData: public wxGDIRefData
{
public:
wxBitmapRefData();
virtual ~wxBitmapRefData();
+ virtual bool IsOk() const { return m_pixmap || m_pixbuf; }
+
GdkPixmap *m_pixmap;
GdkPixbuf *m_pixbuf;
wxMask *m_mask;
wxCHECK_MSG(Ok(), bmp, wxT("invalid bitmap"));
- if (newx==M_BMPDATA->m_width && newy==M_BMPDATA->m_height)
- return *this;
-
int width = wxMax(newx, 1);
int height = wxMax(newy, 1);
width = wxMin(width, clipwidth);
// images, but the only one which preserves sharp edges
gdk_pixbuf_scale(
pixbuf, pixbuf_scaled,
- 0, 0, width, height, clipx, clipy, scale_x, scale_y,
+ 0, 0, width, height, -clipx, -clipy, scale_x, scale_y,
GDK_INTERP_NEAREST);
g_object_unref(pixbuf);
gdk_pixbuf_scale(
pixbuf, pixbuf_scaled,
- 0, 0, width, height, clipx, clipy, scale_x, scale_y,
+ 0, 0, width, height, -clipx, -clipy, scale_x, scale_y,
GDK_INTERP_NEAREST);
g_object_unref(pixbuf);
return bmp;
}
+#if wxUSE_IMAGE
+
bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
{
UnRef();
return image;
}
-bool wxBitmap::IsOk() const
-{
- return (m_refData != NULL) &&
- (
- M_BMPDATA->m_pixbuf ||
- M_BMPDATA->m_pixmap
- );
-}
+#endif // wxUSE_IMAGE
int wxBitmap::GetHeight() const
{
{
wxCHECK_MSG( Ok(), false, wxT("invalid bitmap") );
+#if wxUSE_IMAGE
// Try to save the bitmap via wxImage handlers:
wxImage image = ConvertToImage();
return image.Ok() && image.SaveFile(name, type);
+#else // !wxUSE_IMAGE
+ wxUnusedVar(name);
+ wxUnusedVar(type);
+
+ return false;
+#endif // wxUSE_IMAGE
}
bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type )
M_BMPDATA->m_mask->m_bitmap = mask;
}
}
+#if wxUSE_IMAGE
else // try if wxImage can load it
{
wxImage image;
if (image.LoadFile(name, type) && image.Ok())
CreateFromImage(image, -1);
}
+#endif // wxUSE_IMAGE
return Ok();
}
gdk_pixbuf_render_pixmap_and_mask(M_BMPDATA->m_pixbuf,
&M_BMPDATA->m_pixmap,
pmask,
- wxIMAGE_ALPHA_THRESHOLD);
+ 0x80 /* alpha threshold */);
}
return M_BMPDATA->m_pixmap;
gdk_pixbuf_get_has_alpha(M_BMPDATA->m_pixbuf);
}
-void wxBitmap::UseAlpha()
-{
- GdkPixbuf* pixbuf = GetPixbuf();
- // add alpha if necessary
- if (!gdk_pixbuf_get_has_alpha(pixbuf))
- {
- M_BMPDATA->m_pixbuf = NULL;
- AllocExclusive();
- M_BMPDATA->m_pixbuf = gdk_pixbuf_add_alpha(pixbuf, false, 0, 0, 0);
- g_object_unref(pixbuf);
- }
-}
-
-wxObjectRefData* wxBitmap::CreateRefData() const
+wxGDIRefData* wxBitmap::CreateGDIRefData() const
{
return new wxBitmapRefData;
}
-wxObjectRefData* wxBitmap::CloneRefData(const wxObjectRefData* data) const
+wxGDIRefData* wxBitmap::CloneGDIRefData(const wxGDIRefData* data) const
{
const wxBitmapRefData* oldRef = wx_static_cast(const wxBitmapRefData*, data);
wxBitmapRefData* newRef = new wxBitmapRefData;
return newRef;
}
-//-----------------------------------------------------------------------------
-// wxBitmapHandler
-//-----------------------------------------------------------------------------
-
-IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxBitmapHandlerBase)
-
/* static */ void wxBitmap::InitStandardHandlers()
{
// TODO: Insert handler based on GdkPixbufs handler later