From: Václav Slavík Date: Thu, 28 Feb 2013 16:28:52 +0000 (+0000) Subject: Add wxBitmap(NSImage*) ctor to wxOSX. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/72625b36b6fdaea839a5132e8f5d52dea7155bec?ds=sidebyside Add wxBitmap(NSImage*) ctor to wxOSX. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73574 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/osx/bitmap.h b/include/wx/osx/bitmap.h index 904a4b0314..eba46c6a1c 100644 --- a/include/wx/osx/bitmap.h +++ b/include/wx/osx/bitmap.h @@ -105,6 +105,7 @@ public: // creates an bitmap from the native image format wxBitmap(CGImageRef image); + wxBitmap(WX_NSImage image); // If depth is omitted, will create a bitmap compatible with the display wxBitmap(int width, int height, int depth = -1) { (void)Create(width, height, depth); } @@ -129,6 +130,7 @@ public: virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1); bool Create( CGImageRef image ); + bool Create( WX_NSImage image ); // virtual bool Create( WXHICON icon) ; virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE); diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index 1161256016..22efcde42a 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -1005,6 +1005,17 @@ IconRef wxBitmap::CreateIconRef() const #if wxOSX_USE_COCOA +wxBitmap::wxBitmap(WX_NSImage image) +{ + (void)Create(image); +} + +bool wxBitmap::Create(WX_NSImage image) +{ + wxCFRef cgimage(wxOSXCreateCGImageFromNSImage(image)); + return Create(cgimage); +} + WX_NSImage wxBitmap::GetNSImage() const { wxCFRef< CGImageRef > cgimage(CreateCGImage());