]> git.saurik.com Git - wxWidgets.git/commitdiff
Add wxImage::ClearAlpha().
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 9 Apr 2010 13:15:20 +0000 (13:15 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 9 Apr 2010 13:15:20 +0000 (13:15 +0000)
This simple method can be used to remove alpha channel from the image.

See #10915.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63922 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/image.h
interface/wx/image.h
src/common/image.cpp

index ac8bcb5aed8286052f42d00fc62c7b79d66dd71f..db31c5502cdd661f2972cd468eb5c4ec58a8b8b1 100644 (file)
@@ -428,6 +428,7 @@ All:
 - Fix output buffer overflow in wxBase64Decode() (Eric W. Savage).
 - Added bilinear image resizing algorithm to wxImage (bishop).
 - Fix bug with position argument in wxImage::Size() (Byron Sorgdrager).
+- Added wxImage::ClearAlpha() (Javier Torres).
 - Fix bug with parsing concatenated switches in wxCmdLineParser (Mike Funduc).
 - Added wxMBConv::cMB2WC(wxCharBuffer) and cWC2MB(wxWCharBuffer) overloads.
 - Added wxAny class; a modern, backwards-incompatible replacement for
index e0e05f67e2c2b0b59e927bfaf1f2e20c7a6119fe..cb602383d1f7badf2440795cf2ab2ecbaf958f46 100644 (file)
@@ -451,6 +451,7 @@ public:
     bool HasAlpha() const { return GetAlpha() != NULL; }
     void SetAlpha(unsigned char *alpha = NULL, bool static_data=false);
     void InitAlpha();
+    void ClearAlpha();
 
     // return true if this pixel is masked or has alpha less than specified
     // threshold
index 04772440941a910b95fd996ccf9d00390fa10004..77c7321e9d9ff277b7c5b320070dd69b20e287f5 100644 (file)
@@ -1396,6 +1396,16 @@ public:
     */
     void SetAlpha(int x, int y, unsigned char alpha);
 
+    /**
+        Removes the alpha channel from the image.
+
+        This function should only be called if the image has alpha channel data,
+        use HasAlpha() to check for this.
+
+        @since 2.9.1
+    */
+    void ClearAlpha();
+
     /**
         Sets the image data without performing checks.
 
index 6dddaefb3c764b236070e6d788f0981adf790106..4fb2b0c2548c79b7b698390783e09122580c6ea3 100644 (file)
@@ -1857,6 +1857,17 @@ void wxImage::InitAlpha()
     }
 }
 
+void wxImage::ClearAlpha()
+{
+    wxCHECK_RET( HasAlpha(), wxT("image already doesn't have an alpha channel") );
+
+    if ( !M_IMGDATA->m_staticAlpha )
+        free( M_IMGDATA->m_alpha );
+
+    M_IMGDATA->m_alpha = NULL;
+}
+
+
 // ----------------------------------------------------------------------------
 // mask support
 // ----------------------------------------------------------------------------