X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/86e9492322866946b1ca35fbbf4ccbe7c54913dc..23af264e462cfd05f5d01f9fa6cb32e1b1ea4985:/src/mac/carbon/bitmap.cpp diff --git a/src/mac/carbon/bitmap.cpp b/src/mac/carbon/bitmap.cpp index bd373e6ef1..3a2d1991b7 100644 --- a/src/mac/carbon/bitmap.cpp +++ b/src/mac/carbon/bitmap.cpp @@ -51,6 +51,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject ) // we don't dare premultiplied alpha yet #define wxMAC_USE_PREMULTIPLIED_ALPHA 0 +#if wxUSE_BMPBUTTON + void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType ) { memset( info , 0 , sizeof(ControlButtonContentInfo) ) ; @@ -122,6 +124,8 @@ void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ) } } +#endif //wxUSE_BMPBUTTON + #define M_BITMAPDATA ((wxBitmapRefData *)m_refData) void wxBitmapRefData::Init() @@ -369,7 +373,10 @@ IconRef wxBitmapRefData::GetIconRef() // transform into IconRef static int iconCounter = 2 ; - OSStatus err = RegisterIconRefFromIconFamily( 'WXNG' , (OSType) iconCounter, iconFamily, &m_iconRef ) ; +#ifdef __WXDEBUG__ + OSStatus err = +#endif + RegisterIconRefFromIconFamily( 'WXNG' , (OSType) iconCounter, iconFamily, &m_iconRef ) ; wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ; // we have to retain a reference, as Unregister will decrement it AcquireIconRef( m_iconRef ) ; @@ -454,7 +461,7 @@ PicHandle wxBitmapRefData::GetPictHandle() return m_pictHandle ; } -#if wxMAC_USE_CORE_GRAPHICS +#ifdef __WXMAC_OSX__ void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size) { wxMemoryBuffer* membuf = (wxMemoryBuffer*) info ; @@ -809,15 +816,19 @@ void wxBitmap::EndRawAccess() bool wxBitmap::CreateFromXpm(const char **bits) { +#if wxUSE_IMAGE wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") ) wxXPMDecoder decoder; wxImage img = decoder.ReadData(bits); wxCHECK_MSG( img.Ok(), FALSE, wxT("invalid bitmap data") ) *this = wxBitmap(img); return TRUE; +#else + return FALSE; +#endif } -#if wxMAC_USE_CORE_GRAPHICS +#ifdef __WXMAC_OSX__ WXCGIMAGEREF wxBitmap::CGImageCreate() const { wxCHECK_MSG( Ok(), NULL , wxT("invalid bitmap") ) ; @@ -907,11 +918,13 @@ bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type) } else { +#if wxUSE_IMAGE wxImage loadimage(filename, type); if (loadimage.Ok()) { *this = loadimage; return true; } +#endif } wxLogWarning(wxT("no bitmap handler for type %d defined."), type); return false; @@ -934,6 +947,8 @@ bool wxBitmap::Create(void *data, wxBitmapType type, int width, int height, int return handler->Create(this, data, type, width, height, depth); } +#if wxUSE_IMAGE + wxBitmap::wxBitmap(const wxImage& image, int depth) { wxCHECK_RET( image.Ok(), wxT("invalid image") ) @@ -1016,6 +1031,7 @@ wxImage wxBitmap::ConvertToImage() const bool hasAlpha = false ; bool hasMask = false ; + int maskBytesPerRow = 0 ; unsigned char *alpha = NULL ; unsigned char *mask = NULL ; if ( HasAlpha() ) @@ -1027,6 +1043,7 @@ wxImage wxBitmap::ConvertToImage() const { hasMask = true ; mask = (unsigned char*) GetMask()->GetRawAccess() ; + maskBytesPerRow = GetMask()->GetBytesPerRow() ; } if ( hasAlpha ) @@ -1044,8 +1061,9 @@ wxImage wxBitmap::ConvertToImage() const static const int MASK_BLUE = 3; static const int MASK_BLUE_REPLACEMENT = 2; - for (int yy = 0; yy < height; yy++) + for (int yy = 0; yy < height; yy++ , mask += maskBytesPerRow ) { + unsigned char * maskp = mask ; for (int xx = 0; xx < width; xx++) { long color = *((long*) source) ; @@ -1055,7 +1073,7 @@ wxImage wxBitmap::ConvertToImage() const unsigned char b = (color&0x000000FF); if ( hasMask ) { - if ( *mask++ == 0 ) + if ( *maskp++ == 0 ) { if ( r == MASK_RED && g == MASK_GREEN && b == MASK_BLUE ) b = MASK_BLUE_REPLACEMENT ; @@ -1082,6 +1100,7 @@ wxImage wxBitmap::ConvertToImage() const return image; } +#endif //wxUSE_IMAGE bool wxBitmap::SaveFile(const wxString& filename, wxBitmapType type, const wxPalette *palette) const @@ -1094,9 +1113,10 @@ bool wxBitmap::SaveFile(const wxString& filename, wxBitmapType type, } else { +#if wxUSE_IMAGE wxImage image = ConvertToImage(); - return image.SaveFile(filename, type); +#endif } wxLogWarning(wxT("no bitmap handler for type %d defined."), type);