#endif
else
{
+#ifndef __LP64__
info->contentType = kControlContentPictHandle ;
info->u.picture = bmap->GetPictHandle() ;
+#endif
}
}
}
m_hasAlpha = false;
}
+wxBitmapRefData::wxBitmapRefData(const wxBitmapRefData &tocopy)
+{
+ Init();
+ Create(tocopy.m_width, tocopy.m_height, tocopy.m_depth);
+
+ if (tocopy.m_bitmapMask)
+ m_bitmapMask = new wxMask(*tocopy.m_bitmapMask);
+
+ unsigned char* dest = (unsigned char*)GetRawAccess();
+ unsigned char* source = (unsigned char*)tocopy.GetRawAccess();
+ size_t numbytes = tocopy.m_width * tocopy.m_height * 4;
+
+ for (size_t i=0; i<numbytes; i++)
+ {
+ *dest++ = *source++;
+ }
+
+ UseAlpha(tocopy.m_hasAlpha);
+
+ // TODO: Copy palette?
+}
+
wxBitmapRefData::wxBitmapRefData()
{
Init() ;
m_hBitmap = NULL ;
Rect rect = { 0 , 0 , m_height , m_width } ;
+#ifndef __LP64__
verify_noerr( NewGWorldFromPtr( (GWorldPtr*) &m_hBitmap , k32ARGBPixelFormat , &rect , NULL , NULL , 0 ,
(char*) data , m_bytesPerRow ) ) ;
wxASSERT_MSG( m_hBitmap , wxT("Unable to create GWorld context") ) ;
-
+#endif
m_ok = ( m_hBitmap != NULL ) ;
return m_ok ;
memset( data , 0 , size ) ;
Rect rect = { 0 , 0 , height , width } ;
+#ifndef __LP64__
verify_noerr( NewGWorldFromPtr( (GWorldPtr*) &m_hMaskBitmap , k32ARGBPixelFormat , &rect , NULL , NULL , 0 ,
(char*) data , m_maskBytesPerRow ) ) ;
wxASSERT_MSG( m_hMaskBitmap , wxT("Unable to create GWorld context for alpha mask") ) ;
+#endif
m_maskMemBuf.UngetWriteBuf(size) ;
#if !wxMAC_USE_CORE_GRAPHICS
}
else
{
+#ifndef __LP64__
DisposeGWorld( m_hMaskBitmap ) ;
+#endif
m_hMaskBitmap = NULL ;
m_maskBytesPerRow = 0 ;
}
{
if ( m_pictHandle == NULL )
{
+#ifndef __LP64__
CGrafPtr origPort = NULL ;
GDHandle origDev = NULL ;
GWorldPtr wp = NULL ;
SetGWorld( origPort , origDev ) ;
if ( clipRgn )
DisposeRgn( clipRgn ) ;
+#endif
}
return m_pictHandle ;
membuf = new wxMemoryBuffer( m_memBuf ) ;
}
-
- CGColorSpaceRef colorSpace = wxMacGetGenericRGBColorSpace();
- CGDataProviderRef dataProvider =
- CGDataProviderCreateWithData(
- membuf , (const void *)membuf->GetData() , imageSize,
- wxMacMemoryBufferReleaseProc );
- image =
+
+ CGDataProviderRef dataProvider = NULL ;
+ if ( m_depth == 1 )
+ {
+ wxMemoryBuffer* maskBuf = new wxMemoryBuffer( m_width * m_height );
+ unsigned char * maskBufData = (unsigned char *) maskBuf->GetData();
+ unsigned char * bufData = (unsigned char *) membuf->GetData() ;
+ // copy one color component
+ for( int i = 0 ; i < m_width * m_height ; ++i )
+ maskBufData[i] = bufData[i*4+3];
+ dataProvider =
+ CGDataProviderCreateWithData(
+ maskBuf , (const void *) maskBufData , m_width * m_height,
+ wxMacMemoryBufferReleaseProc );
+ // as we are now passing the mask buffer to the data provider, we have
+ // to release the membuf ourselves
+ delete membuf ;
+
+ image = ::CGImageMaskCreate( w, h, 8, 8, m_width , dataProvider, NULL, false );
+ }
+ else
+ {
+ CGColorSpaceRef colorSpace = wxMacGetGenericRGBColorSpace();
+ dataProvider =
+ CGDataProviderCreateWithData(
+ membuf , (const void *)membuf->GetData() , imageSize,
+ wxMacMemoryBufferReleaseProc );
+ image =
::CGImageCreate(
w, h, 8 , 32 , 4 * m_width , colorSpace, alphaInfo ,
dataProvider, NULL , false , kCGRenderingIntentDefault );
+ }
CGDataProviderRelease( dataProvider);
}
else
m_iconRef = NULL ;
}
+#ifndef __LP64__
if ( m_pictHandle )
{
KillPicture( m_pictHandle ) ;
DisposeGWorld( MAC_WXHBITMAP(m_hMaskBitmap) ) ;
m_hMaskBitmap = NULL ;
}
-
+#endif
if (m_bitmapMask)
{
delete m_bitmapMask;
bit = x % 8 ;
mask = 1 << bit ;
- if ( !(linestart[index] & mask ) )
+ if ( linestart[index] & mask )
{
*destination++ = 0xFF ;
*destination++ = 0 ;
LoadFile(filename, type);
}
+wxObjectRefData* wxBitmap::CreateRefData() const
+{
+ return new wxBitmapRefData;
+}
+
+wxObjectRefData* wxBitmap::CloneRefData(const wxObjectRefData* data) const
+{
+ return new wxBitmapRefData(*wx_static_cast(const wxBitmapRefData *, data));
+}
+
void * wxBitmap::GetRawAccess() const
{
wxCHECK_MSG( Ok() , NULL , wxT("invalid bitmap") ) ;
return M_BITMAPDATA->GetDepth();
}
-#if WXWIN_COMPATIBILITY_2_4
-int wxBitmap::GetQuality() const
-{
- return 0;
-}
-
-void wxBitmap::SetQuality(int WXUNUSED(quality))
-{
-}
-#endif
-
wxMask *wxBitmap::GetMask() const
{
wxCHECK_MSG( Ok(), (wxMask *) NULL, wxT("invalid bitmap") );
void wxBitmap::SetWidth(int w)
{
- if (!M_BITMAPDATA)
- m_refData = new wxBitmapRefData;
-
+ AllocExclusive();
M_BITMAPDATA->SetWidth(w);
}
void wxBitmap::SetHeight(int h)
{
- if (!M_BITMAPDATA)
- m_refData = new wxBitmapRefData;
-
+ AllocExclusive();
M_BITMAPDATA->SetHeight(h);
}
void wxBitmap::SetDepth(int d)
{
- if (!M_BITMAPDATA)
- m_refData = new wxBitmapRefData;
-
+ AllocExclusive();
M_BITMAPDATA->SetDepth(d);
}
void wxBitmap::SetOk(bool isOk)
{
- if (!M_BITMAPDATA)
- m_refData = new wxBitmapRefData;
-
+ AllocExclusive();
M_BITMAPDATA->SetOk(isOk);
}
void wxBitmap::SetPalette(const wxPalette& palette)
{
- if (!M_BITMAPDATA)
- m_refData = new wxBitmapRefData;
-
+ AllocExclusive();
M_BITMAPDATA->m_bitmapPalette = palette ;
}
#endif // wxUSE_PALETTE
void wxBitmap::SetMask(wxMask *mask)
{
- if (!M_BITMAPDATA)
- m_refData = new wxBitmapRefData;
-
+ AllocExclusive();
// Remove existing mask if there is one.
delete M_BITMAPDATA->m_bitmapMask;
Init() ;
}
+wxMask::wxMask(const wxMask &tocopy)
+{
+ Init();
+
+ m_bytesPerRow = tocopy.m_bytesPerRow;
+ m_width = tocopy.m_width;
+ m_height = tocopy.m_height;
+
+ size_t size = m_bytesPerRow * m_height;
+ unsigned char* dest = (unsigned char*)m_memBuf.GetWriteBuf( size );
+ unsigned char* source = (unsigned char*)tocopy.m_memBuf.GetData();
+ for (size_t i=0; i<size; i++)
+ {
+ *dest++ = *source++;
+ }
+
+ m_memBuf.UngetWriteBuf( size ) ;
+ RealizeNative() ;
+}
+
// Construct a mask from a bitmap and a colour indicating
// the transparent area
wxMask::wxMask( const wxBitmap& bitmap, const wxColour& colour )
wxMask::~wxMask()
{
+#ifndef __LP64__
if ( m_maskBitmap )
{
DisposeGWorld( (GWorldPtr)m_maskBitmap ) ;
m_maskBitmap = NULL ;
}
+#endif
}
void wxMask::Init()
void wxMask::RealizeNative()
{
+#ifndef __LP64__
if ( m_maskBitmap )
{
DisposeGWorld( (GWorldPtr)m_maskBitmap ) ;
(GWorldPtr*) &m_maskBitmap , k32ARGBPixelFormat , &rect , NULL , NULL , 0 ,
(char*) m_memBuf.GetData() , m_bytesPerRow ) ;
verify_noerr( err ) ;
+#endif
}
// Create a mask from a mono bitmap (copies the bitmap).