/////////////////////////////////////////////////////////////////////////////
-// Name: bitmap.cpp
+// Name: src/mac/carbon/bitmap.cpp
// Purpose: wxBitmap
// Author: Stefan Csomor
// Modified by:
#include "wx/wxprec.h"
#include "wx/bitmap.h"
-#include "wx/icon.h"
-#include "wx/log.h"
-#include "wx/image.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/log.h"
+ #include "wx/dcmemory.h"
+ #include "wx/icon.h"
+ #include "wx/image.h"
+#endif
+
#include "wx/metafile.h"
#include "wx/xpmdecod.h"
#endif
#include "wx/mac/uma.h"
-#include "wx/dcmemory.h"
// Implementation Notes
// --------------------
bool wxBitmapRefData::Create( int w , int h , int d )
{
- m_width = w ;
- m_height = h ;
+ m_width = wxMax(1, w);
+ m_height = wxMax(1, h);
m_depth = d ;
m_bytesPerRow = w * 4 ;
PicHandle pic = GetPictHandle() ;
SetIconFamilyData( iconFamily, 'PICT' , (Handle) pic ) ;
}
-
// transform into IconRef
-
+#if defined( __WXMAC_OSX__ ) && MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
+ // cleaner version existing from 10.3 upwards
+ HLock((Handle) iconFamily);
+ OSStatus err = GetIconRefFromIconFamilyPtr( *iconFamily, GetHandleSize((Handle) iconFamily), &m_iconRef );
+ HUnlock((Handle) iconFamily);
+ wxASSERT_MSG( err == noErr , wxT("Error when constructing icon ref") );
+#else
static int iconCounter = 2 ;
OSStatus err = RegisterIconRefFromIconFamily( 'WXNG' , (OSType) iconCounter, iconFamily, &m_iconRef ) ;
// we have to retain a reference, as Unregister will decrement it
AcquireIconRef( m_iconRef ) ;
UnregisterIconRef( 'WXNG' , (OSType) iconCounter ) ;
- DisposeHandle( (Handle) iconFamily ) ;
++iconCounter ;
+#endif
+ DisposeHandle( (Handle) iconFamily ) ;
}
return m_iconRef ;