X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7e7f40ed5f201c4e83624af00adb842b5d4544b3..e015e7f3acef09b57bcd34e8f6780a19afdfd97b:/src/mac/carbon/bitmap.cpp diff --git a/src/mac/carbon/bitmap.cpp b/src/mac/carbon/bitmap.cpp index b661b95f8f..4339cf4b57 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) ) ; @@ -106,6 +108,10 @@ void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ) { ReleaseIconRef( info->u.iconRef ) ; } + else if ( info->contentType == kControlNoContent ) + { + // there's no bitmap at all, fall through silently + } else if ( info->contentType == kControlContentPictHandle ) { // owned by the bitmap, no release here @@ -122,6 +128,8 @@ void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ) } } +#endif //wxUSE_BMPBUTTON + #define M_BITMAPDATA ((wxBitmapRefData *)m_refData) void wxBitmapRefData::Init() @@ -359,9 +367,6 @@ IconRef wxBitmapRefData::GetIconRef() } else { - iconFamily = (IconFamilyHandle) NewHandle(8) ; - (**iconFamily).resourceType = kIconFamilyType ; - (**iconFamily).resourceSize = sizeof(OSType) + sizeof(Size); PicHandle pic = GetPictHandle() ; SetIconFamilyData( iconFamily, 'PICT' , (Handle) pic ) ; } @@ -369,7 +374,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 +462,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 ; @@ -698,6 +706,7 @@ bool wxBitmap::CopyFromIcon(const wxIcon& icon) EndRawAccess() ; DisposeHandle( imagehandle ) ; DisposeHandle( maskhandle ) ; + created = true ; } DisposeHandle( (Handle) iconFamily ) ; @@ -809,15 +818,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 +920,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 +949,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") ) @@ -1060,15 +1077,12 @@ wxImage wxBitmap::ConvertToImage() const { if ( *maskp++ == 0 ) { - if ( r == MASK_RED && g == MASK_GREEN && b == MASK_BLUE ) - b = MASK_BLUE_REPLACEMENT ; - else - { - r = MASK_RED ; - g = MASK_GREEN ; - b = MASK_BLUE ; - } + r = MASK_RED ; + g = MASK_GREEN ; + b = MASK_BLUE ; } + else if ( r == MASK_RED && g == MASK_GREEN && b == MASK_BLUE ) + b = MASK_BLUE_REPLACEMENT ; } else if ( hasAlpha ) *alpha++ = a ; @@ -1085,6 +1099,7 @@ wxImage wxBitmap::ConvertToImage() const return image; } +#endif //wxUSE_IMAGE bool wxBitmap::SaveFile(const wxString& filename, wxBitmapType type, const wxPalette *palette) const @@ -1097,9 +1112,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);