From: Stefan Csomor Date: Tue, 4 Jan 2005 06:22:37 +0000 (+0000) Subject: falling back to wxImage handler X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1996c23f8c7255c51aacc8f1a2f8f904d440ea4f?hp=4b60ad0d8c1ea4f840ad0b9b7c11270322634394 falling back to wxImage handler git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31225 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/mac/carbon/icon.cpp b/src/mac/carbon/icon.cpp index bd1937bc2a..ab1dffe712 100644 --- a/src/mac/carbon/icon.cpp +++ b/src/mac/carbon/icon.cpp @@ -19,6 +19,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap) #endif +#include "wx/image.h" #include "wx/mac/private.h" @@ -61,14 +62,31 @@ bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type, { UnRef(); - m_refData = new wxBitmapRefData; - - wxBitmapHandler *handler = FindHandler((wxBitmapType)type); - + wxBitmapHandler *handler = FindHandler(type); + if ( handler ) - return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight); + { + m_refData = new wxBitmapRefData; + return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight ); + } else - return FALSE; + { + wxImage loadimage(filename, type); + if (loadimage.Ok()) + { + if ( desiredWidth == -1 ) + desiredWidth = loadimage.GetWidth() ; + if ( desiredHeight == -1 ) + desiredHeight = loadimage.GetHeight() ; + if ( desiredWidth != loadimage.GetWidth() || desiredHeight != loadimage.GetHeight() ) + loadimage.Rescale( desiredWidth , desiredHeight ) ; + wxBitmap bmp( loadimage ); + wxIcon *icon = (wxIcon*)(&bmp); + *this = *icon; + return true; + } + } + return false ; } void wxIcon::CopyFromBitmap(const wxBitmap& bmp)