X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a8562f5520233a37151f453f91a82cb9c4636510..31ae546e1684e7a7f7c743e18572ef34fcf19151:/src/mac/bitmap.cpp?ds=inline diff --git a/src/mac/bitmap.cpp b/src/mac/bitmap.cpp index 1a59104b9e..a37654c059 100644 --- a/src/mac/bitmap.cpp +++ b/src/mac/bitmap.cpp @@ -10,13 +10,12 @@ ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ +#pragma implementation "bitmapbase.h" #pragma implementation "bitmap.h" #endif -#include "wx/wx.h" -#include "wx/setup.h" -#include "wx/utils.h" -#include "wx/palette.h" +#include "wx/defs.h" + #include "wx/bitmap.h" #include "wx/icon.h" #include "wx/log.h" @@ -26,9 +25,11 @@ #if !USE_SHARED_LIBRARIES IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxBitmapBase , wxGDIObject ) +IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandlerBase, wxObject ) #endif -#ifdef __UNIX__ +#ifdef __DARWIN__ #include #else #include @@ -239,7 +240,14 @@ wxBitmapRefData::~wxBitmapRefData() } } -wxList wxBitmap::sm_handlers; +wxList wxBitmapBase::sm_handlers; + + +bool wxBitmap::CopyFromIcon(const wxIcon& icon) +{ + Ref(icon) ; + return true; +} wxBitmap::wxBitmap() { @@ -540,55 +548,68 @@ wxBitmap::wxBitmap(const wxImage& image, int depth) // Create picture - Create( width , height , wxDisplayDepth() ) ; - wxBitmap maskBitmap( width, height, 1); + Create( width , height , 32 ) ; CGrafPtr origPort ; GDHandle origDevice ; - LockPixels( GetGWorldPixMap(GetHBITMAP()) ); - LockPixels( GetGWorldPixMap(maskBitmap.GetHBITMAP()) ); + PixMapHandle pixMap = GetGWorldPixMap(GetHBITMAP()) ; + LockPixels( pixMap ); GetGWorld( &origPort , &origDevice ) ; SetGWorld( GetHBITMAP() , NULL ) ; // Render image - wxColour rgb, maskcolor(image.GetMaskRed(), image.GetMaskGreen(), image.GetMaskBlue()); - RGBColor color; - RGBColor white = { 0xffff, 0xffff, 0xffff }; - RGBColor black = { 0 , 0 , 0 }; + RGBColor colorRGB ; register unsigned char* data = image.GetData(); - - int index = 0; + char* destinationBase = GetPixBaseAddr( pixMap ); + register unsigned char* destination = (unsigned char*) destinationBase ; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { - rgb.Set(data[index++], data[index++], data[index++]); - color = rgb.GetPixel(); - SetCPixel( x , y , &color ) ; - if (image.HasMask()) - { - SetGWorld(maskBitmap.GetHBITMAP(), NULL); - if (rgb == maskcolor) { - SetCPixel(x,y, &white); - } - else { - SetCPixel(x,y, &black); - } - SetGWorld(GetHBITMAP(), NULL); - } + *destination++ = 0 ; + *destination++ = *data++ ; + *destination++ = *data++ ; + *destination++ = *data++ ; } - } // for height + 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); - // Create mask - if ( image.HasMask() ) { - SetMask(new wxMask( maskBitmap )); + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + if ( data[0] == image.GetMaskRed() && data[1] == image.GetMaskGreen() && data[2] == image.GetMaskBlue() ) + { + SetCPixel(x,y, &white); + } + else { + SetCPixel(x,y, &black); + } + data += 3 ; + } + } // for height + SetGWorld(GetHBITMAP(), NULL); + SetMask(new wxMask( maskBitmap )); + UnlockPixels( GetGWorldPixMap(maskBitmap.GetHBITMAP()) ); } UnlockPixels( GetGWorldPixMap(GetHBITMAP()) ); - UnlockPixels( GetGWorldPixMap(maskBitmap.GetHBITMAP()) ); SetGWorld( origPort, origDevice ); } @@ -834,7 +855,7 @@ PicHandle wxBitmap::GetPict() const if( mask ) { -#ifdef __UNIX__ +#ifdef __DARWIN__ RGBColor trans = white; #else RGBBackColor( &gray );