X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/650c0aa9180563eece310851973171cfaac83ad8..2e334012b4babcf063fbe79540c4c154cd54ab2b:/src/gtk/bitmap.cpp diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index 0a2cf3fca6..18fb4f02b0 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -181,12 +181,14 @@ GdkBitmap *wxMask::GetBitmap() const // 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; @@ -363,6 +365,8 @@ wxBitmap wxBitmap::Rescale(int clipx, int clipy, int clipwidth, int clipheight, return bmp; } +#if wxUSE_IMAGE + bool wxBitmap::CreateFromImage(const wxImage& image, int depth) { UnRef(); @@ -593,14 +597,7 @@ wxImage wxBitmap::ConvertToImage() const 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 { @@ -692,9 +689,16 @@ bool wxBitmap::SaveFile( const wxString &name, wxBitmapType type, const wxPalett { 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 ) @@ -712,12 +716,14 @@ 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(); } @@ -786,7 +792,7 @@ GdkPixmap *wxBitmap::GetPixmap() const 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; @@ -896,8 +902,8 @@ void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp) const bool hasAlpha = HasAlpha(); // allow access if bpp is valid and matches existence of alpha if (pixbuf != NULL && ( - bpp == 24 && !hasAlpha || - bpp == 32 && hasAlpha)) + (bpp == 24 && !hasAlpha) || + (bpp == 32 && hasAlpha))) { data.m_height = gdk_pixbuf_get_height( pixbuf ); data.m_width = gdk_pixbuf_get_width( pixbuf ); @@ -917,12 +923,12 @@ bool wxBitmap::HasAlpha() const gdk_pixbuf_get_has_alpha(M_BMPDATA->m_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; @@ -962,12 +968,6 @@ wxObjectRefData* wxBitmap::CloneRefData(const wxObjectRefData* data) const return newRef; } -//----------------------------------------------------------------------------- -// wxBitmapHandler -//----------------------------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxBitmapHandlerBase) - /* static */ void wxBitmap::InitStandardHandlers() { // TODO: Insert handler based on GdkPixbufs handler later