IMPLEMENT_DYNAMIC_CLASS(wxImage, wxObject)
-wxImage::wxImage()
-{
-}
-
wxImage::wxImage( int width, int height, bool clear )
{
Create( width, height, clear );
{
if( xFactor == 1 && yFactor == 1 )
return Copy() ;
-
+
wxImage image;
wxCHECK_MSG( Ok(), image, wxT("invalid image") );
long old_height = M_IMGDATA->m_height,
old_width = M_IMGDATA->m_width;
-
+
wxCHECK_MSG( (old_height > 0) && (old_width > 0), image,
wxT("invalid old image size") );
maskRed = M_IMGDATA->m_maskRed;
maskGreen = M_IMGDATA->m_maskGreen;
maskBlue =M_IMGDATA->m_maskBlue ;
-
+
image.SetMaskColour( M_IMGDATA->m_maskRed,
M_IMGDATA->m_maskGreen,
M_IMGDATA->m_maskBlue );
}
char unsigned *source_data = M_IMGDATA->m_data;
char unsigned *target_data = data;
-
+
for (long y = 0; y < height; y++)
{
for (long x = 0; x < width; x++)
return true;
}
+bool wxImage::ConvertAlphaToMask(unsigned char threshold)
+{
+ if (!HasAlpha())
+ return true;
+
+ unsigned char mr, mg, mb;
+ if (!FindFirstUnusedColour(&mr, &mg, &mb))
+ {
+ wxLogError( _("No unused colour in image being masked.") );
+ return false;
+ }
+
+ SetMask(true);
+ SetMaskColour(mr, mg, mb);
+
+ unsigned char *imgdata = GetData();
+ unsigned char *alphadata = GetAlpha();
+
+ int w = GetWidth();
+ int h = GetHeight();
+
+ for (int y = 0; y < h; y++)
+ {
+ for (int x = 0; x < w; x++, imgdata += 3, alphadata++)
+ {
+ if (*alphadata < threshold)
+ {
+ imgdata[0] = mr;
+ imgdata[1] = mg;
+ imgdata[2] = mb;
+ }
+ }
+ }
+
+ free(M_IMGDATA->m_alpha);
+ M_IMGDATA->m_alpha = NULL;
+
+ return true;
+}
+
#if wxUSE_PALETTE
// Palette functions
bool wxImageHandler::CallDoCanRead(wxInputStream& stream)
{
- off_t posOld = stream.TellI();
+ wxFileSize_t posOld = stream.TellI();
if ( posOld == wxInvalidOffset )
{
// can't test unseekable stream