RGBColor color;
mask = (GWorldPtr) GetMask()->GetMaskBitmap();
- submask = wxMacCreateGWorld(rect.width, rect.height, 1);
+ submask = wxMacCreateGWorld(rect.width, rect.height, GetMask()->GetDepth() );
LockPixels(GetGWorldPixMap(mask));
LockPixels(GetGWorldPixMap(submask));
return true;
}
}
- wxLogWarning("no bitmap handler for type %d defined.", type);
+ wxLogWarning(wxT("no bitmap handler for type %d defined."), type);
return false;
}
wxBitmapHandler *handler = FindHandler(type);
if ( handler == NULL ) {
- wxLogWarning("no bitmap handler for type %d defined.", type);
+ wxLogWarning(wxT("no bitmap handler for type %d defined."), type);
return FALSE;
}
destinationBase += ((**pixMap).rowBytes & 0x7fff);
destination = (unsigned char*) destinationBase ;
}
- if ( image.HasMask() )
+ if ( image.HasAlpha() )
+ {
+ unsigned char *alpha = image.GetAlpha();
+
+ wxColour maskcolor(image.GetMaskRed(), image.GetMaskGreen(), image.GetMaskBlue());
+ RGBColor color ;
+ wxBitmap maskBitmap ;
+
+ maskBitmap.Create( width, height, 24);
+ LockPixels( GetGWorldPixMap( (GWorldPtr) maskBitmap.GetHBITMAP()) );
+ SetGWorld( (GWorldPtr) maskBitmap.GetHBITMAP(), NULL);
+
+ for (int y = 0; y < height; y++)
+ {
+ for (int x = 0; x < width; x++)
+ {
+ memset( &color , 255 - *alpha , sizeof( color ) );
+ SetCPixel(x,y, &color);
+
+ alpha += 1 ;
+ }
+ } // for height
+ SetGWorld( (GWorldPtr) GetHBITMAP(), NULL);
+ SetMask(new wxMask( maskBitmap ));
+ UnlockPixels( GetGWorldPixMap( (GWorldPtr) maskBitmap.GetHBITMAP()) );
+ }
+ else if ( image.HasMask() )
{
data = image.GetData();
SetCPixel(x,y, &white);
}
else {
- SetCPixel(x,y, &black);
+ SetCPixel(x,y, &black);
}
data += 3 ;
}
return image.SaveFile(filename, type);
}
- wxLogWarning("no bitmap handler for type %d defined.", type);
+ wxLogWarning(wxT("no bitmap handler for type %d defined."), type);
return false;
}
wxCHECK_MSG( bitmap.Ok(), false, wxT("Invalid bitmap"));
- wxCHECK_MSG(bitmap.GetDepth() == 1, false,
- wxT("Cannot create mask from colour bitmap"));
-
- m_maskBitmap = wxMacCreateGWorld(bitmap.GetWidth(), bitmap.GetHeight(), 1);
+ m_depth = bitmap.GetDepth() ;
+ m_maskBitmap = wxMacCreateGWorld(bitmap.GetWidth(), bitmap.GetHeight(), bitmap.GetDepth() );
Rect rect = { 0,0, bitmap.GetHeight(), bitmap.GetWidth() };
LockPixels( GetGWorldPixMap( (GWorldPtr) m_maskBitmap) );
wxCHECK_MSG( bitmap.Ok(), false, wxT("Illigal bitmap"));
- m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 );
+ m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 );
+ m_depth = 1 ;
LockPixels( GetGWorldPixMap( (GWorldPtr) m_maskBitmap ) );
LockPixels( GetGWorldPixMap( (GWorldPtr) bitmap.GetHBITMAP() ) );
RGBColor maskColor = MAC_WXCOLORREF(colour.GetPixel());
public:
inline wxPICTResourceHandler()
{
- m_name = "Macintosh Pict resource";
- m_extension = "";
+ m_name = wxT("Macintosh Pict resource");
+ m_extension = wxEmptyString;
m_type = wxBITMAP_TYPE_PICT_RESOURCE;
};
int desiredWidth, int desiredHeight)
{
Str255 theName ;
-
-#if TARGET_CARBON
- c2pstrcpy( (StringPtr) theName , name ) ;
-#else
- strcpy( (char *) theName , name ) ;
- c2pstr( (char *)theName ) ;
-#endif
-
+ wxMacStringToPascal( name , theName ) ;
+
PicHandle thePict = (PicHandle ) GetNamedResource( 'PICT' , theName ) ;
if ( thePict )
{