no message
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11317 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -547,55 +547,68 @@ wxBitmap::wxBitmap(const wxImage& image, int depth)
|
|||||||
|
|
||||||
// Create picture
|
// Create picture
|
||||||
|
|
||||||
Create( width , height , wxDisplayDepth() ) ;
|
Create( width , height , 32 ) ;
|
||||||
wxBitmap maskBitmap( width, height, 1);
|
|
||||||
|
|
||||||
CGrafPtr origPort ;
|
CGrafPtr origPort ;
|
||||||
GDHandle origDevice ;
|
GDHandle origDevice ;
|
||||||
|
|
||||||
LockPixels( GetGWorldPixMap(GetHBITMAP()) );
|
PixMapHandle pixMap = GetGWorldPixMap(GetHBITMAP()) ;
|
||||||
LockPixels( GetGWorldPixMap(maskBitmap.GetHBITMAP()) );
|
LockPixels( pixMap );
|
||||||
|
|
||||||
GetGWorld( &origPort , &origDevice ) ;
|
GetGWorld( &origPort , &origDevice ) ;
|
||||||
SetGWorld( GetHBITMAP() , NULL ) ;
|
SetGWorld( GetHBITMAP() , NULL ) ;
|
||||||
|
|
||||||
// Render image
|
// Render image
|
||||||
wxColour rgb, maskcolor(image.GetMaskRed(), image.GetMaskGreen(), image.GetMaskBlue());
|
RGBColor colorRGB ;
|
||||||
RGBColor color;
|
|
||||||
RGBColor white = { 0xffff, 0xffff, 0xffff };
|
|
||||||
RGBColor black = { 0 , 0 , 0 };
|
|
||||||
|
|
||||||
register unsigned char* data = image.GetData();
|
register unsigned char* data = image.GetData();
|
||||||
|
char* destinationBase = GetPixBaseAddr( pixMap );
|
||||||
int index = 0;
|
register unsigned char* destination = (unsigned char*) destinationBase ;
|
||||||
for (int y = 0; y < height; y++)
|
for (int y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < width; x++)
|
for (int x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
rgb.Set(data[index++], data[index++], data[index++]);
|
*destination++ = 0 ;
|
||||||
color = rgb.GetPixel();
|
*destination++ = *data++ ;
|
||||||
SetCPixel( x , y , &color ) ;
|
*destination++ = *data++ ;
|
||||||
if (image.HasMask())
|
*destination++ = *data++ ;
|
||||||
|
}
|
||||||
|
destinationBase += ((**pixMap).rowBytes & 0x7fff);
|
||||||
|
destination = (unsigned char*) destinationBase ;
|
||||||
|
}
|
||||||
|
if ( image.HasMask() )
|
||||||
{
|
{
|
||||||
|
data = image.GetData();
|
||||||
|
|
||||||
|
wxColour maskcolor(image.GetMaskRed(), image.GetMaskGreen(), image.GetMaskBlue());
|
||||||
|
RGBColor white = { 0xffff, 0xffff, 0xffff };
|
||||||
|
RGBColor black = { 0 , 0 , 0 };
|
||||||
|
wxBitmap maskBitmap ;
|
||||||
|
|
||||||
|
maskBitmap.Create( width, height, 1);
|
||||||
|
LockPixels( GetGWorldPixMap(maskBitmap.GetHBITMAP()) );
|
||||||
SetGWorld(maskBitmap.GetHBITMAP(), NULL);
|
SetGWorld(maskBitmap.GetHBITMAP(), NULL);
|
||||||
if (rgb == maskcolor) {
|
|
||||||
|
for (int y = 0; y < height; y++)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < width; x++)
|
||||||
|
{
|
||||||
|
if ( data[0] == image.GetMaskRed() && data[1] == image.GetMaskRed() && data[2] == image.GetMaskRed() )
|
||||||
|
{
|
||||||
SetCPixel(x,y, &white);
|
SetCPixel(x,y, &white);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SetCPixel(x,y, &black);
|
SetCPixel(x,y, &black);
|
||||||
}
|
}
|
||||||
SetGWorld(GetHBITMAP(), NULL);
|
data += 3 ;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // for height
|
} // for height
|
||||||
|
SetGWorld(GetHBITMAP(), NULL);
|
||||||
// Create mask
|
|
||||||
if ( image.HasMask() ) {
|
|
||||||
SetMask(new wxMask( maskBitmap ));
|
SetMask(new wxMask( maskBitmap ));
|
||||||
|
UnlockPixels( GetGWorldPixMap(maskBitmap.GetHBITMAP()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
UnlockPixels( GetGWorldPixMap(GetHBITMAP()) );
|
UnlockPixels( GetGWorldPixMap(GetHBITMAP()) );
|
||||||
UnlockPixels( GetGWorldPixMap(maskBitmap.GetHBITMAP()) );
|
|
||||||
SetGWorld( origPort, origDevice );
|
SetGWorld( origPort, origDevice );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -547,55 +547,68 @@ wxBitmap::wxBitmap(const wxImage& image, int depth)
|
|||||||
|
|
||||||
// Create picture
|
// Create picture
|
||||||
|
|
||||||
Create( width , height , wxDisplayDepth() ) ;
|
Create( width , height , 32 ) ;
|
||||||
wxBitmap maskBitmap( width, height, 1);
|
|
||||||
|
|
||||||
CGrafPtr origPort ;
|
CGrafPtr origPort ;
|
||||||
GDHandle origDevice ;
|
GDHandle origDevice ;
|
||||||
|
|
||||||
LockPixels( GetGWorldPixMap(GetHBITMAP()) );
|
PixMapHandle pixMap = GetGWorldPixMap(GetHBITMAP()) ;
|
||||||
LockPixels( GetGWorldPixMap(maskBitmap.GetHBITMAP()) );
|
LockPixels( pixMap );
|
||||||
|
|
||||||
GetGWorld( &origPort , &origDevice ) ;
|
GetGWorld( &origPort , &origDevice ) ;
|
||||||
SetGWorld( GetHBITMAP() , NULL ) ;
|
SetGWorld( GetHBITMAP() , NULL ) ;
|
||||||
|
|
||||||
// Render image
|
// Render image
|
||||||
wxColour rgb, maskcolor(image.GetMaskRed(), image.GetMaskGreen(), image.GetMaskBlue());
|
RGBColor colorRGB ;
|
||||||
RGBColor color;
|
|
||||||
RGBColor white = { 0xffff, 0xffff, 0xffff };
|
|
||||||
RGBColor black = { 0 , 0 , 0 };
|
|
||||||
|
|
||||||
register unsigned char* data = image.GetData();
|
register unsigned char* data = image.GetData();
|
||||||
|
char* destinationBase = GetPixBaseAddr( pixMap );
|
||||||
int index = 0;
|
register unsigned char* destination = (unsigned char*) destinationBase ;
|
||||||
for (int y = 0; y < height; y++)
|
for (int y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < width; x++)
|
for (int x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
rgb.Set(data[index++], data[index++], data[index++]);
|
*destination++ = 0 ;
|
||||||
color = rgb.GetPixel();
|
*destination++ = *data++ ;
|
||||||
SetCPixel( x , y , &color ) ;
|
*destination++ = *data++ ;
|
||||||
if (image.HasMask())
|
*destination++ = *data++ ;
|
||||||
|
}
|
||||||
|
destinationBase += ((**pixMap).rowBytes & 0x7fff);
|
||||||
|
destination = (unsigned char*) destinationBase ;
|
||||||
|
}
|
||||||
|
if ( image.HasMask() )
|
||||||
{
|
{
|
||||||
|
data = image.GetData();
|
||||||
|
|
||||||
|
wxColour maskcolor(image.GetMaskRed(), image.GetMaskGreen(), image.GetMaskBlue());
|
||||||
|
RGBColor white = { 0xffff, 0xffff, 0xffff };
|
||||||
|
RGBColor black = { 0 , 0 , 0 };
|
||||||
|
wxBitmap maskBitmap ;
|
||||||
|
|
||||||
|
maskBitmap.Create( width, height, 1);
|
||||||
|
LockPixels( GetGWorldPixMap(maskBitmap.GetHBITMAP()) );
|
||||||
SetGWorld(maskBitmap.GetHBITMAP(), NULL);
|
SetGWorld(maskBitmap.GetHBITMAP(), NULL);
|
||||||
if (rgb == maskcolor) {
|
|
||||||
|
for (int y = 0; y < height; y++)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < width; x++)
|
||||||
|
{
|
||||||
|
if ( data[0] == image.GetMaskRed() && data[1] == image.GetMaskRed() && data[2] == image.GetMaskRed() )
|
||||||
|
{
|
||||||
SetCPixel(x,y, &white);
|
SetCPixel(x,y, &white);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SetCPixel(x,y, &black);
|
SetCPixel(x,y, &black);
|
||||||
}
|
}
|
||||||
SetGWorld(GetHBITMAP(), NULL);
|
data += 3 ;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // for height
|
} // for height
|
||||||
|
SetGWorld(GetHBITMAP(), NULL);
|
||||||
// Create mask
|
|
||||||
if ( image.HasMask() ) {
|
|
||||||
SetMask(new wxMask( maskBitmap ));
|
SetMask(new wxMask( maskBitmap ));
|
||||||
|
UnlockPixels( GetGWorldPixMap(maskBitmap.GetHBITMAP()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
UnlockPixels( GetGWorldPixMap(GetHBITMAP()) );
|
UnlockPixels( GetGWorldPixMap(GetHBITMAP()) );
|
||||||
UnlockPixels( GetGWorldPixMap(maskBitmap.GetHBITMAP()) );
|
|
||||||
SetGWorld( origPort, origDevice );
|
SetGWorld( origPort, origDevice );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user