1. remove UseAlpha() on platforms that don't need it and call it automatically from ~wxPixelData instead of requiring explicit call; deprecate wxPixelData::UseAlpha()
2. don't call UngetRawData() if GetRawData() failed
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47295
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// raw bitmap access support functions
void *GetRawData(wxPixelDataBase& data, int bpp);
void UngetRawData(wxPixelDataBase& data);
// raw bitmap access support functions
void *GetRawData(wxPixelDataBase& data, int bpp);
void UngetRawData(wxPixelDataBase& data);
wxPalette* GetPalette() const;
void SetPalette(const wxPalette& palette);
wxPalette* GetPalette() const;
void SetPalette(const wxPalette& palette);
void UngetRawData(wxPixelDataBase& data);
bool HasAlpha() const;
void UngetRawData(wxPixelDataBase& data);
bool HasAlpha() const;
protected:
bool CreateFromImage(const wxImage& image, int depth);
protected:
bool CreateFromImage(const wxImage& image, int depth);
void UngetRawData(wxPixelDataBase& data);
bool HasAlpha() const;
void UngetRawData(wxPixelDataBase& data);
bool HasAlpha() const;
protected:
bool CreateFromImage(const wxImage& image, int depth);
protected:
bool CreateFromImage(const wxImage& image, int depth);
// these functions are internal and shouldn't be used, they risk to
// disappear in the future
bool HasAlpha() const;
// these functions are internal and shouldn't be used, they risk to
// disappear in the future
bool HasAlpha() const;
// implementation only from now on
// -------------------------------
// implementation only from now on
// -------------------------------
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
-#ifndef _WX_RAWBMP_H_BASE_
-#define _WX_RAWBMP_H_BASE_
+#ifndef _WX_RAWBMP_H_
+#define _WX_RAWBMP_H_
// return true if this iterator is valid
bool IsOk() const { return m_ptr != NULL; }
// return true if this iterator is valid
bool IsOk() const { return m_ptr != NULL; }
// dtor unlocks the bitmap
~wxPixelDataIn()
{
// dtor unlocks the bitmap
~wxPixelDataIn()
{
- m_bmp.UngetRawData(*this);
+ if ( m_pixels.IsOk() )
+ {
+#if defined(__WXMSW__) || defined(__WXMAC__)
+ // this is a hack to mark wxBitmap as using alpha channel
+ if ( Format::HasAlpha )
+ m_bmp.UseAlpha();
+#endif
+ m_bmp.UngetRawData(*this);
+ }
+ // else: don't call UngetRawData() if GetRawData() failed
- // call this to indicate that we should use the alpha channel
- void UseAlpha() { m_bmp.UseAlpha(); }
+#if WXWIN_COMPATIBILITY_2_8
+ // not needed anymore, calls to it should be simply removed
+ wxDEPRECATED( inline void UseAlpha() {} );
+#endif
// private: -- see comment in the beginning of the file
// private: -- see comment in the beginning of the file
#endif //wxUSE_GUI
template <class Image, class PixelFormat = wxPixelFormatFor<Image> >
#endif //wxUSE_GUI
template <class Image, class PixelFormat = wxPixelFormatFor<Image> >
-#endif // _WX_RAWBMP_H_BASE_
-
wxLogError(_T("Failed to gain raw access to bitmap data"));
return;
}
wxLogError(_T("Failed to gain raw access to bitmap data"));
return;
}
wxAlphaPixelData::Iterator p(data);
for ( int y = 0; y < SIZE; ++y )
{
wxAlphaPixelData::Iterator p(data);
for ( int y = 0; y < SIZE; ++y )
{
wxAlphaPixelData::Iterator p(data);
for ( int y = 0; y < REAL_SIZE; ++y )
wxAlphaPixelData::Iterator p(data);
for ( int y = 0; y < REAL_SIZE; ++y )
-void wxBitmap::UseAlpha()
-{ // TODO
-}
-
// ========================================================================
// wxMask
// ========================================================================
// ========================================================================
// wxMask
// ========================================================================
gdk_pixbuf_get_has_alpha(M_BMPDATA->m_pixbuf);
}
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
{
return new wxBitmapRefData;
wxObjectRefData* wxBitmap::CreateRefData() const
{
return new wxBitmapRefData;
-void wxBitmap::UseAlpha()
-{
-}
-
//-----------------------------------------------------------------------------
// wxBitmapHandler
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// wxBitmapHandler
//-----------------------------------------------------------------------------
-void wxBitmap::UseAlpha()
-{
-}
-
bool wxBitmap::HasAlpha() const
{
return false;
bool wxBitmap::HasAlpha() const
{
return false;