X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/524c47aa3adf2af11a3069fd5da035a604f08f66..72a4fa54d980d514f2cbd15e43cdb1f54902566e:/src/osx/core/bitmap.cpp?ds=sidebyside diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index 83e6b6c6f5..157cb84b51 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -287,8 +287,8 @@ bool wxBitmapRefData::Create( int w , int h , int d ) m_depth = d ; m_hBitmap = NULL ; - m_bytesPerRow = GetBestBytesPerRow( w * 4 ) ; - size_t size = m_bytesPerRow * h ; + m_bytesPerRow = GetBestBytesPerRow( m_width * 4 ) ; + size_t size = m_bytesPerRow * m_height ; void* data = m_memBuf.GetWriteBuf( size ) ; if ( data != NULL ) { @@ -496,8 +496,13 @@ IconRef wxBitmapRefData::GetIconRef() } } HUnlock( data ); + OSStatus err = SetIconFamilyData( iconFamily, dataType , data ); - wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ); + if ( err != noErr ) + { + wxFAIL_MSG("Error when adding bitmap"); + } + DisposeHandle( data ); } else @@ -608,13 +613,13 @@ PicHandle wxBitmapRefData::GetPictHandle() err = GraphicsExportDoExport(exporter, NULL); CGImageRelease( imageRef ); - size_t handleSize = GetHandleSize( (Handle) m_pictHandle ); - // the 512 bytes header is only needed for pict files, but not in memory - if ( handleSize >= 512 ) - { - memmove( *m_pictHandle , (char*)(*m_pictHandle)+512, handleSize - 512 ); - SetHandleSize( (Handle) m_pictHandle, handleSize - 512 ); - } + size_t handleSize = GetHandleSize( (Handle) m_pictHandle ); + // the 512 bytes header is only needed for pict files, but not in memory + if ( handleSize >= 512 ) + { + memmove( *m_pictHandle , (char*)(*m_pictHandle)+512, handleSize - 512 ); + SetHandleSize( (Handle) m_pictHandle, handleSize - 512 ); + } } CloseComponent( exporter ); } @@ -785,6 +790,12 @@ wxBitmapRefData::~wxBitmapRefData() Free() ; } + + +// ---------------------------------------------------------------------------- +// wxBitmap +// ---------------------------------------------------------------------------- + bool wxBitmap::CopyFromIcon(const wxIcon& icon) { bool created = false ; @@ -890,14 +901,6 @@ bool wxBitmap::CopyFromIcon(const wxIcon& icon) return true; } -wxBitmap::wxBitmap() -{ -} - -wxBitmap::~wxBitmap() -{ -} - wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits) { wxBitmapRefData* bitmapRefData; @@ -952,11 +955,6 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits } /* bitmapRefData->IsOk() */ } -wxBitmap::wxBitmap(int w, int h, int d) -{ - (void)Create(w, h, d); -} - wxBitmap::wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth) { (void) Create(data, type, width, height, depth); @@ -974,7 +972,7 @@ wxGDIRefData* wxBitmap::CreateGDIRefData() const wxGDIRefData* wxBitmap::CloneGDIRefData(const wxGDIRefData* data) const { - return new wxBitmapRefData(*wx_static_cast(const wxBitmapRefData *, data)); + return new wxBitmapRefData(*static_cast(data)); } void * wxBitmap::GetRawAccess() const @@ -1021,7 +1019,7 @@ IconRef wxBitmap::CreateIconRef() const } #endif -#if wxOSX_USE_COCOA_OR_IPHONE +#if wxOSX_USE_COCOA WX_NSImage wxBitmap::GetNSImage() const { @@ -1031,6 +1029,15 @@ WX_NSImage wxBitmap::GetNSImage() const #endif +#if wxOSX_USE_IPHONE + +WX_UIImage wxBitmap::GetUIImage() const +{ + wxCFRef< CGImageRef > cgimage(CreateCGImage()); + return wxOSXCreateUIImageFromCGImage( cgimage ); +} + +#endif wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const { wxCHECK_MSG( Ok() && @@ -1164,7 +1171,7 @@ wxBitmap::wxBitmap(const wxImage& image, int depth) int height = image.GetHeight(); wxBitmapRefData* bitmapRefData; - + m_refData = bitmapRefData = new wxBitmapRefData( width , height , depth ) ; if ( bitmapRefData->IsOk()) @@ -1384,7 +1391,7 @@ int wxBitmap::GetDepth() const wxMask *wxBitmap::GetMask() const { - wxCHECK_MSG( Ok(), (wxMask *) NULL, wxT("invalid bitmap") ); + wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") ); return M_BITMAPDATA->m_bitmapMask; } @@ -1647,7 +1654,7 @@ WXHBITMAP wxMask::GetHBITMAP() const // Standard Handlers // ---------------------------------------------------------------------------- -#if !defined( __LP64__ ) && !defined(__WXOSX_IPHONE__) +#if !defined( __LP64__ ) && !defined(__WXOSX_IPHONE__) class WXDLLEXPORT wxPICTResourceHandler: public wxBitmapHandler { @@ -1661,8 +1668,11 @@ public: SetType(wxBITMAP_TYPE_PICT_RESOURCE); }; - virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, - int desiredWidth, int desiredHeight); + virtual bool LoadFile(wxBitmap *bitmap, + const wxString& name, + wxBitmapType type, + int desiredWidth, + int desiredHeight); }; IMPLEMENT_DYNAMIC_CLASS(wxPICTResourceHandler, wxBitmapHandler) @@ -1670,7 +1680,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxPICTResourceHandler, wxBitmapHandler) bool wxPICTResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, - long WXUNUSED(flags), + wxBitmapType WXUNUSED(type), int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight)) {