// 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__
- // returns a Pict from the bitmap content
- PicHandle GetPictHandle();
#endif
CGContextRef GetBitmapContext() const;
bool m_ok;
mutable CGImageRef m_cgImageRef;
- IconRef m_iconRef;
#ifndef __WXOSX_IPHONE__
- PicHandle m_pictHandle;
+ IconRef m_iconRef;
#endif
+
CGContextRef m_hBitmap;
};
info->contentType = kControlContentCGImageRef ;
info->u.imageRef = (CGImageRef) bmap->CreateCGImage() ;
}
- else
- {
-#ifndef __LP64__
- info->contentType = kControlContentPictHandle ;
- info->u.picture = bmap->GetPictHandle() ;
-#endif
- }
}
}
#ifndef __WXOSX_IPHONE__
m_iconRef = NULL ;
- m_pictHandle = NULL ;
#endif
m_hBitmap = NULL ;
wxCHECK_MSG( IsOk(), NULL, wxT("invalid bitmap") ) ;
wxASSERT( m_rawAccessCount == 0 ) ;
#ifndef __WXOSX_IPHONE__
- wxASSERT_MSG( m_pictHandle == NULL && m_iconRef == NULL ,
- wxT("Currently, modifing bitmaps that are used in controls already is not supported") ) ;
+ wxASSERT_MSG( m_iconRef == NULL ,
+ wxT("Currently, modifing bitmaps that are used in controls already is not supported") ) ;
#endif
++m_rawAccessCount ;
OSType dataType = 0 ;
OSType maskType = 0 ;
+ // since we don't have PICT conversion available, use
+ // the next larger standard icon size
+ // TODO: Use NSImage
+ if (sz <= 16)
+ sz = 16;
+ else if ( sz <= 32)
+ sz = 32;
+ else if ( sz <= 48)
+ sz = 48;
+ else if ( sz <= 128)
+ sz = 128;
+ else if ( sz <= 256)
+ sz = 256;
+ else if ( sz <= 512)
+ sz = 512;
+ else if ( sz <= 1024)
+ sz = 1024;
+
switch (sz)
{
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
+ case 1024:
+ dataType = kIconServices1024PixelDataARGB;
+ break;
+#endif
+ case 512:
+ dataType = kIconServices512PixelDataARGB;
+ break;
+
+ case 256:
+ dataType = kIconServices256PixelDataARGB;
+ break;
+
case 128:
dataType = kIconServices128PixelDataARGB ;
break;
DisposeHandle( maskdata ) ;
}
}
- else
- {
- PicHandle pic = GetPictHandle() ;
- SetIconFamilyData( iconFamily, 'PICT' , (Handle) pic ) ;
- }
// transform into IconRef
// cleaner version existing from 10.3 upwards
return m_iconRef ;
}
-PicHandle wxBitmapRefData::GetPictHandle()
-{
- return m_pictHandle ;
-}
#endif
CGImageRef wxBitmapRefData::CreateCGImage() const
ReleaseIconRef( m_iconRef ) ;
m_iconRef = NULL ;
}
-
-#ifndef __LP64__
- if ( m_pictHandle )
- {
- m_pictHandle = NULL ;
- }
-#endif
#endif
if ( m_hBitmap )
{
{
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() ;
(void) Create(data, type, width, height, depth);
}
+wxBitmap::wxBitmap(int width, int height, const wxDC& WXUNUSED(dc))
+{
+ (void) Create(width, height);
+}
+
wxBitmap::wxBitmap(const wxString& filename, wxBitmapType type)
{
LoadFile(filename, type);
#if wxOSX_USE_COCOA
+wxBitmap::wxBitmap(WX_NSImage image)
+{
+ (void)Create(image);
+}
+
+bool wxBitmap::Create(WX_NSImage image)
+{
+ wxCFRef<CGImageRef> cgimage(wxOSXCreateCGImageFromNSImage(image));
+ return Create(cgimage);
+}
+
WX_NSImage wxBitmap::GetNSImage() const
{
wxCFRef< CGImageRef > cgimage(CreateCGImage());
return M_BITMAPDATA->IsOk() ;
}
-
bool wxBitmap::Create(CGImageRef image)
{
UnRef();
return true;
}
+wxBitmap wxMask::GetBitmap() const
+{
+ wxBitmap bitmap(m_width, m_height, 1);
+ unsigned char* dst = static_cast<unsigned char*>(bitmap.BeginRawAccess());
+ const int dst_stride = bitmap.GetBitmapData()->GetBytesPerRow();
+ const unsigned char* src = static_cast<unsigned char*>(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 ;
class WXDLLEXPORT wxJPEGResourceHandler: public wxBundleResourceHandler
{
- DECLARE_DYNAMIC_CLASS(wxPNGResourceHandler)
+ DECLARE_DYNAMIC_CLASS(wxJPEGResourceHandler)
public:
inline wxJPEGResourceHandler()
return false ;
}
+/* static */
+wxBitmap wxBitmapHelpers::NewFromPNGData(const void* data, size_t size)
+{
+ wxCFRef<CGDataProviderRef>
+ provider(CGDataProviderCreateWithData(NULL, data, size, NULL) );
+ wxCFRef<CGImageRef>
+ image(CGImageCreateWithPNGDataProvider(provider, NULL, true,
+ kCGRenderingIntentDefault));
+
+ return wxBitmap(image);
+}
+
void wxBitmap::InitStandardHandlers()
{
#if wxOSX_USE_COCOA_OR_CARBON