+// ----------------------------------------------------------------------------
+// alpha channel support
+// ----------------------------------------------------------------------------
+
+void wxImage::SetAlpha(int x, int y, unsigned char alpha)
+{
+ wxCHECK_RET( Ok() && HasAlpha(), wxT("invalid image or no alpha channel") );
+
+ int w = M_IMGDATA->m_width,
+ h = M_IMGDATA->m_height;
+
+ wxCHECK_RET( x >=0 && y >= 0 && x < w && y < h, wxT("invalid image index") );
+
+ M_IMGDATA->m_alpha[y*w + x] = alpha;
+}
+
+unsigned char wxImage::GetAlpha(int x, int y) const
+{
+ wxCHECK_MSG( Ok() && HasAlpha(), 0, wxT("invalid image or no alpha channel") );
+
+ int w = M_IMGDATA->m_width,
+ h = M_IMGDATA->m_height;
+
+ wxCHECK_MSG( x >=0 && y >= 0 && x < w && y < h, 0, wxT("invalid image index") );
+
+ return M_IMGDATA->m_alpha[y*w + x];
+}
+
+bool wxImage::ConvertColourToAlpha( unsigned char r, unsigned char g, unsigned char b )
+{
+ SetAlpha( NULL );
+
+ int w = M_IMGDATA->m_width,
+ h = M_IMGDATA->m_height;
+
+ unsigned char *alpha = GetAlpha();
+ unsigned char *data = GetData();
+
+ int x,y;
+ for (y = 0; y < h; y++)
+ for (x = 0; x < w; x++)
+ {
+ *alpha = *data;
+ alpha++;
+ *data = r;
+ data++;
+ *data = g;
+ data++;
+ *data = b;
+ data++;
+ }
+
+ return true;
+}
+
+void wxImage::SetAlpha( unsigned char *alpha )
+{
+ wxCHECK_RET( Ok(), wxT("invalid image") );
+
+ if ( !alpha )
+ {
+ alpha = (unsigned char *)malloc(M_IMGDATA->m_width*M_IMGDATA->m_height);
+ }
+
+ free(M_IMGDATA->m_alpha);
+ M_IMGDATA->m_alpha = alpha;
+}
+
+unsigned char *wxImage::GetAlpha() const
+{
+ wxCHECK_MSG( Ok(), (unsigned char *)NULL, wxT("invalid image") );
+
+ return M_IMGDATA->m_alpha;
+}
+
+// ----------------------------------------------------------------------------
+// mask support
+// ----------------------------------------------------------------------------
+