X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/37d8aa5b686ec3b48aa9a6c480dd06738c5a9e64..ff0d660405e85eb4b411edb0cafc6c6f7733ae55:/src/osx/core/bitmap.cpp diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index 2cd8885f51..1161256016 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -98,15 +98,10 @@ public: // rescaled to 16 x 16 bool HasNativeSize(); +#ifndef __WXOSX_IPHONE__ // caller should increase ref count if needed longer // than the bitmap exists IconRef GetIconRef(); - -#ifndef __WXOSX_IPHONE__ -#ifndef __LP64__ - // returns a Pict from the bitmap content - PicHandle GetPictHandle(); -#endif #endif CGContextRef GetBitmapContext() const; @@ -127,12 +122,10 @@ public: bool m_ok; mutable CGImageRef m_cgImageRef; - IconRef m_iconRef; #ifndef __WXOSX_IPHONE__ -#ifndef __LP64__ - PicHandle m_pictHandle; -#endif + IconRef m_iconRef; #endif + CGContextRef m_hBitmap; }; @@ -193,13 +186,6 @@ void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bi info->contentType = kControlContentCGImageRef ; info->u.imageRef = (CGImageRef) bmap->CreateCGImage() ; } - else - { -#ifndef __LP64__ - info->contentType = kControlContentPictHandle ; - info->u.picture = bmap->GetPictHandle() ; -#endif - } } } @@ -251,9 +237,6 @@ void wxBitmapRefData::Init() #ifndef __WXOSX_IPHONE__ m_iconRef = NULL ; -#ifndef __LP64__ - m_pictHandle = NULL ; -#endif #endif m_hBitmap = NULL ; @@ -385,10 +368,6 @@ void *wxBitmapRefData::BeginRawAccess() wxCHECK_MSG( IsOk(), NULL, wxT("invalid bitmap") ) ; wxASSERT( m_rawAccessCount == 0 ) ; #ifndef __WXOSX_IPHONE__ -#ifndef __LP64__ - wxASSERT_MSG( m_pictHandle == NULL, - wxT("Currently, modifing bitmaps that are used in controls already is not supported") ) ; -#endif wxASSERT_MSG( m_iconRef == NULL , wxT("Currently, modifing bitmaps that are used in controls already is not supported") ) ; #endif @@ -438,8 +417,7 @@ IconRef wxBitmapRefData::GetIconRef() OSType dataType = 0 ; OSType maskType = 0 ; -#ifdef __LP64__ - // since we don't have PICT conversion available under 64 bit, use + // since we don't have PICT conversion available, use // the next larger standard icon size // TODO: Use NSImage if (sz <= 16) @@ -456,7 +434,6 @@ IconRef wxBitmapRefData::GetIconRef() sz = 512; else if ( sz <= 1024) sz = 1024; -#endif switch (sz) { @@ -624,13 +601,6 @@ IconRef wxBitmapRefData::GetIconRef() DisposeHandle( maskdata ) ; } } - else - { -#ifndef __LP64__ - PicHandle pic = GetPictHandle() ; - SetIconFamilyData( iconFamily, 'PICT' , (Handle) pic ) ; -#endif - } // transform into IconRef // cleaner version existing from 10.3 upwards @@ -645,15 +615,6 @@ IconRef wxBitmapRefData::GetIconRef() return m_iconRef ; } -#ifndef __WXOSX_IPHONE__ -#ifndef __LP64__ -PicHandle wxBitmapRefData::GetPictHandle() -{ - return m_pictHandle ; -} -#endif -#endif - #endif CGImageRef wxBitmapRefData::CreateCGImage() const @@ -793,13 +754,6 @@ void wxBitmapRefData::Free() ReleaseIconRef( m_iconRef ) ; m_iconRef = NULL ; } - -#ifndef __LP64__ - if ( m_pictHandle ) - { - m_pictHandle = NULL ; - } -#endif #endif if ( m_hBitmap ) { @@ -936,9 +890,9 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits { if ( no_bits == 1 ) { - int linesize = ( the_width / (sizeof(unsigned char) * 8)) ; - if ( the_width % (sizeof(unsigned char) * 8) ) - linesize += sizeof(unsigned char); + int linesize = the_width / 8; + if ( the_width % 8 ) + linesize++; unsigned char* linestart = (unsigned char*) bits ; unsigned char* destptr = (unsigned char*) BeginRawAccess() ; @@ -1695,6 +1649,28 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) return true; } +wxBitmap wxMask::GetBitmap() const +{ + wxBitmap bitmap(m_width, m_height, 1); + unsigned char* dst = static_cast(bitmap.BeginRawAccess()); + const int dst_stride = bitmap.GetBitmapData()->GetBytesPerRow(); + const unsigned char* src = static_cast(GetRawAccess()); + for (int j = 0; j < m_height; j++, src += m_bytesPerRow, dst += dst_stride) + { + unsigned char* d = dst; + for (int i = 0; i < m_width; i++) + { + const unsigned char byte = src[i]; + *d++ = 0xff; + *d++ = byte; + *d++ = byte; + *d++ = byte; + } + } + bitmap.EndRawAccess(); + return bitmap; +} + WXHBITMAP wxMask::GetHBITMAP() const { return m_maskBitmap ; @@ -1739,7 +1715,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxPNGResourceHandler, wxBundleResourceHandler) class WXDLLEXPORT wxJPEGResourceHandler: public wxBundleResourceHandler { - DECLARE_DYNAMIC_CLASS(wxPNGResourceHandler) + DECLARE_DYNAMIC_CLASS(wxJPEGResourceHandler) public: inline wxJPEGResourceHandler()