1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/bitmap.cpp
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #include "wx/bitmap.h"
18 #include "wx/dcmemory.h"
23 #include "wx/metafile.h"
24 #include "wx/xpmdecod.h"
26 #include "wx/rawbmp.h"
28 IMPLEMENT_DYNAMIC_CLASS(wxBitmap
, wxGDIObject
)
29 IMPLEMENT_DYNAMIC_CLASS(wxMask
, wxObject
)
31 #include "wx/osx/uma.h"
32 #ifndef __WXOSX_IPHONE__
33 #include <QuickTime/QuickTime.h>
36 CGColorSpaceRef
wxMacGetGenericRGBColorSpace();
37 CGDataProviderRef
wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer
& buf
);
39 // Implementation Notes
40 // --------------------
42 // we are always working with a 32 bit deep pixel buffer
43 // under QuickDraw its alpha parts are going to be ignored in the GWorld,
44 // therefore we have a separate GWorld there for blitting the mask in
46 // under Quartz then content is transformed into a CGImageRef representing the same data
47 // which can be transferred to the GPU by the OS for fast rendering
49 class WXDLLEXPORT wxBitmapRefData
: public wxGDIRefData
51 friend class WXDLLIMPEXP_FWD_CORE wxIcon
;
52 friend class WXDLLIMPEXP_FWD_CORE wxCursor
;
54 wxBitmapRefData(int width
, int height
, int depth
);
56 wxBitmapRefData(const wxBitmapRefData
&tocopy
);
58 virtual ~wxBitmapRefData();
60 virtual bool IsOk() const { return m_ok
; }
63 void SetOk( bool isOk
) { m_ok
= isOk
; }
65 void SetWidth( int width
) { m_width
= width
; }
66 void SetHeight( int height
) { m_height
= height
; }
67 void SetDepth( int depth
) { m_depth
= depth
; }
69 int GetWidth() const { return m_width
; }
70 int GetHeight() const { return m_height
; }
71 int GetDepth() const { return m_depth
; }
73 void *GetRawAccess() const;
74 void *BeginRawAccess();
77 bool HasAlpha() const { return m_hasAlpha
; }
78 void UseAlpha( bool useAlpha
);
82 wxPalette m_bitmapPalette
;
83 #endif // wxUSE_PALETTE
85 wxMask
* m_bitmapMask
; // Optional mask
86 CGImageRef
CreateCGImage() const;
88 // returns true if the bitmap has a size that
89 // can be natively transferred into a true icon
90 // if no is returned GetIconRef will still produce
91 // an icon but it will be generated via a PICT and
92 // rescaled to 16 x 16
95 // caller should increase ref count if needed longer
96 // than the bitmap exists
99 #ifndef __WXOSX_IPHONE__
100 // returns a Pict from the bitmap content
101 PicHandle
GetPictHandle();
104 CGContextRef
GetBitmapContext() const;
106 int GetBytesPerRow() const { return m_bytesPerRow
; }
108 bool Create(int width
, int height
, int depth
);
116 wxMemoryBuffer m_memBuf
;
117 int m_rawAccessCount
;
119 mutable CGImageRef m_cgImageRef
;
122 #ifndef __WXOSX_IPHONE__
123 PicHandle m_pictHandle
;
125 CGContextRef m_hBitmap
;
129 #define wxMAC_USE_PREMULTIPLIED_ALPHA 1
130 static const int kBestByteAlignement
= 16;
131 static const int kMaskBytesPerPixel
= 1;
133 static int GetBestBytesPerRow( int rawBytes
)
135 return (((rawBytes
)+kBestByteAlignement
-1) & ~(kBestByteAlignement
-1) );
138 #if wxUSE_GUI && !defined(__WXOSX_IPHONE__)
140 // this is used for more controls than just the wxBitmap button, also for notebooks etc
142 void wxMacCreateBitmapButton( ControlButtonContentInfo
*info
, const wxBitmap
& bitmap
, int forceType
)
144 memset( info
, 0 , sizeof(ControlButtonContentInfo
) ) ;
147 wxBitmapRefData
* bmap
= bitmap
.GetBitmapData() ;
151 if ( forceType
== 0 )
153 forceType
= kControlContentCGImageRef
;
156 if ( forceType
== kControlContentIconRef
)
159 wxBitmapRefData
* bmp
= bmap
;
161 if ( !bmap
->HasNativeSize() )
163 // as PICT conversion will only result in a 16x16 icon, let's attempt
164 // a few scales for better results
166 int w
= bitmap
.GetWidth() ;
167 int h
= bitmap
.GetHeight() ;
168 int sz
= wxMax( w
, h
) ;
169 if ( sz
== 24 || sz
== 64 )
171 scaleBmp
= wxBitmap( bitmap
.ConvertToImage().Scale( w
* 2 , h
* 2 ) ) ;
172 bmp
= scaleBmp
.GetBitmapData() ;
176 info
->contentType
= kControlContentIconRef
;
177 info
->u
.iconRef
= bmp
->GetIconRef() ;
178 AcquireIconRef( info
->u
.iconRef
) ;
180 else if ( forceType
== kControlContentCGImageRef
)
182 info
->contentType
= kControlContentCGImageRef
;
183 info
->u
.imageRef
= (CGImageRef
) bmap
->CreateCGImage() ;
188 info
->contentType
= kControlContentPictHandle
;
189 info
->u
.picture
= bmap
->GetPictHandle() ;
195 CGImageRef
wxMacCreateCGImageFromBitmap( const wxBitmap
& bitmap
)
197 wxBitmapRefData
* bmap
= bitmap
.GetBitmapData() ;
200 return (CGImageRef
) bmap
->CreateCGImage();
203 void wxMacReleaseBitmapButton( ControlButtonContentInfo
*info
)
205 if ( info
->contentType
== kControlContentIconRef
)
207 ReleaseIconRef( info
->u
.iconRef
) ;
209 else if ( info
->contentType
== kControlNoContent
)
211 // there's no bitmap at all, fall through silently
213 else if ( info
->contentType
== kControlContentPictHandle
)
215 // owned by the bitmap, no release here
217 else if ( info
->contentType
== kControlContentCGImageRef
)
219 CGImageRelease( info
->u
.imageRef
) ;
223 wxFAIL_MSG(wxT("Unexpected bitmap type") ) ;
227 #endif //wxUSE_BMPBUTTON
229 #define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
231 void wxBitmapRefData::Init()
238 m_bitmapMask
= NULL
;
239 m_cgImageRef
= NULL
;
241 #ifndef __WXOSX_IPHONE__
243 m_pictHandle
= NULL
;
247 m_rawAccessCount
= 0 ;
251 wxBitmapRefData::wxBitmapRefData(const wxBitmapRefData
&tocopy
)
254 Create(tocopy
.m_width
, tocopy
.m_height
, tocopy
.m_depth
);
256 if (tocopy
.m_bitmapMask
)
257 m_bitmapMask
= new wxMask(*tocopy
.m_bitmapMask
);
258 else if (tocopy
.m_hasAlpha
)
261 unsigned char* dest
= (unsigned char*)GetRawAccess();
262 unsigned char* source
= (unsigned char*)tocopy
.GetRawAccess();
263 size_t numbytes
= m_bytesPerRow
* m_height
;
264 memcpy( dest
, source
, numbytes
);
267 wxBitmapRefData::wxBitmapRefData()
272 wxBitmapRefData::wxBitmapRefData( int w
, int h
, int d
)
275 Create( w
, h
, d
) ;
278 bool wxBitmapRefData::Create( int w
, int h
, int d
)
280 m_width
= wxMax(1, w
);
281 m_height
= wxMax(1, h
);
285 m_bytesPerRow
= GetBestBytesPerRow( w
* 4 ) ;
286 size_t size
= m_bytesPerRow
* h
;
287 void* data
= m_memBuf
.GetWriteBuf( size
) ;
290 memset( data
, 0 , size
) ;
291 m_memBuf
.UngetWriteBuf( size
) ;
293 m_hBitmap
= CGBitmapContextCreate((char*) data
, m_width
, m_height
, 8, m_bytesPerRow
, wxMacGetGenericRGBColorSpace(), kCGImageAlphaNoneSkipFirst
);
294 wxASSERT_MSG( m_hBitmap
, wxT("Unable to create CGBitmapContext context") ) ;
295 CGContextTranslateCTM( m_hBitmap
, 0, m_height
);
296 CGContextScaleCTM( m_hBitmap
, 1, -1 );
298 m_ok
= ( m_hBitmap
!= NULL
) ;
303 void wxBitmapRefData::UseAlpha( bool use
)
305 if ( m_hasAlpha
== use
)
310 CGContextRelease( m_hBitmap
);
311 m_hBitmap
= CGBitmapContextCreate((char*) m_memBuf
.GetData(), m_width
, m_height
, 8, m_bytesPerRow
, wxMacGetGenericRGBColorSpace(), m_hasAlpha
? kCGImageAlphaPremultipliedFirst
: kCGImageAlphaNoneSkipFirst
);
312 wxASSERT_MSG( m_hBitmap
, wxT("Unable to create CGBitmapContext context") ) ;
313 CGContextTranslateCTM( m_hBitmap
, 0, m_height
);
314 CGContextScaleCTM( m_hBitmap
, 1, -1 );
317 void *wxBitmapRefData::GetRawAccess() const
319 wxCHECK_MSG( IsOk(), NULL
, wxT("invalid bitmap") ) ;
320 return m_memBuf
.GetData() ;
323 void *wxBitmapRefData::BeginRawAccess()
325 wxCHECK_MSG( IsOk(), NULL
, wxT("invalid bitmap") ) ;
326 wxASSERT( m_rawAccessCount
== 0 ) ;
327 #ifndef __WXOSX_IPHONE__
328 wxASSERT_MSG( m_pictHandle
== NULL
&& m_iconRef
== NULL
,
329 wxT("Currently, modifing bitmaps that are used in controls already is not supported") ) ;
333 // we must destroy an existing cached image, as
334 // the bitmap data may change now
337 CGImageRelease( m_cgImageRef
) ;
338 m_cgImageRef
= NULL
;
341 return m_memBuf
.GetData() ;
344 void wxBitmapRefData::EndRawAccess()
346 wxCHECK_RET( IsOk() , wxT("invalid bitmap") ) ;
347 wxASSERT( m_rawAccessCount
== 1 ) ;
352 bool wxBitmapRefData::HasNativeSize()
355 int h
= GetHeight() ;
356 int sz
= wxMax( w
, h
) ;
358 return ( sz
== 128 || sz
== 48 || sz
== 32 || sz
== 16 );
361 #ifndef __WXOSX_IPHONE__
362 IconRef
wxBitmapRefData::GetIconRef()
364 if ( m_iconRef
== NULL
)
366 // Create Icon Family Handle
368 IconFamilyHandle iconFamily
= (IconFamilyHandle
) NewHandle( 0 );
371 int h
= GetHeight() ;
372 int sz
= wxMax( w
, h
) ;
374 OSType dataType
= 0 ;
375 OSType maskType
= 0 ;
380 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
381 if ( UMAGetSystemVersion() >= 0x1050 )
383 dataType
= kIconServices128PixelDataARGB
;
388 dataType
= kThumbnail32BitData
;
389 maskType
= kThumbnail8BitMask
;
394 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
395 if ( UMAGetSystemVersion() >= 0x1050 )
397 dataType
= kIconServices48PixelDataARGB
;
402 dataType
= kHuge32BitData
;
403 maskType
= kHuge8BitMask
;
408 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
409 if ( UMAGetSystemVersion() >= 0x1050 )
411 dataType
= kIconServices32PixelDataARGB
;
416 dataType
= kLarge32BitData
;
417 maskType
= kLarge8BitMask
;
422 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
423 if ( UMAGetSystemVersion() >= 0x1050 )
425 dataType
= kIconServices16PixelDataARGB
;
430 dataType
= kSmall32BitData
;
431 maskType
= kSmall8BitMask
;
441 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
442 if ( maskType
== 0 && UMAGetSystemVersion() >= 0x1050 )
444 size_t datasize
= sz
* sz
* 4 ;
445 Handle data
= NewHandle( datasize
) ;
447 unsigned char* ptr
= (unsigned char*) *data
;
448 memset( ptr
, 0, datasize
);
449 bool hasAlpha
= HasAlpha() ;
450 wxMask
*mask
= m_bitmapMask
;
451 unsigned char * sourcePtr
= (unsigned char*) GetRawAccess() ;
452 unsigned char * masksourcePtr
= mask
? (unsigned char*) mask
->GetRawAccess() : NULL
;
454 for ( int y
= 0 ; y
< h
; ++y
, sourcePtr
+= m_bytesPerRow
, masksourcePtr
+= mask
? mask
->GetBytesPerRow() : 0 )
456 unsigned char * source
= sourcePtr
;
457 unsigned char * masksource
= masksourcePtr
;
458 unsigned char * dest
= ptr
+ y
* sz
* 4 ;
459 unsigned char a
, r
, g
, b
;
461 for ( int x
= 0 ; x
< w
; ++x
)
470 a
= 0xFF - *masksource
++ ;
472 else if ( !hasAlpha
)
476 #if wxMAC_USE_PREMULTIPLIED_ALPHA
477 // this must be non-premultiplied data
478 if ( a
!= 0xFF && a
!= 0 )
494 OSStatus err
= SetIconFamilyData( iconFamily
, dataType
, data
);
495 wxASSERT_MSG( err
== noErr
, wxT("Error when adding bitmap") );
496 DisposeHandle( data
);
501 // setup the header properly
504 Handle maskdata
= NULL
;
505 unsigned char * maskptr
= NULL
;
506 unsigned char * ptr
= NULL
;
507 size_t datasize
, masksize
;
509 datasize
= sz
* sz
* 4 ;
510 data
= NewHandle( datasize
) ;
512 ptr
= (unsigned char*) *data
;
513 memset( ptr
, 0, datasize
) ;
516 maskdata
= NewHandle( masksize
) ;
518 maskptr
= (unsigned char*) *maskdata
;
519 memset( maskptr
, 0 , masksize
) ;
521 bool hasAlpha
= HasAlpha() ;
522 wxMask
*mask
= m_bitmapMask
;
523 unsigned char * sourcePtr
= (unsigned char*) GetRawAccess() ;
524 unsigned char * masksourcePtr
= mask
? (unsigned char*) mask
->GetRawAccess() : NULL
;
526 for ( int y
= 0 ; y
< h
; ++y
, sourcePtr
+= m_bytesPerRow
, masksourcePtr
+= mask
? mask
->GetBytesPerRow() : 0 )
528 unsigned char * source
= sourcePtr
;
529 unsigned char * masksource
= masksourcePtr
;
530 unsigned char * dest
= ptr
+ y
* sz
* 4 ;
531 unsigned char * maskdest
= maskptr
+ y
* sz
;
532 unsigned char a
, r
, g
, b
;
534 for ( int x
= 0 ; x
< w
; ++x
)
547 *maskdest
++ = 0xFF - *masksource
++ ;
555 OSStatus err
= SetIconFamilyData( iconFamily
, dataType
, data
) ;
556 wxASSERT_MSG( err
== noErr
, wxT("Error when adding bitmap") ) ;
558 err
= SetIconFamilyData( iconFamily
, maskType
, maskdata
) ;
559 wxASSERT_MSG( err
== noErr
, wxT("Error when adding mask") ) ;
562 HUnlock( maskdata
) ;
563 DisposeHandle( data
) ;
564 DisposeHandle( maskdata
) ;
569 PicHandle pic
= GetPictHandle() ;
570 SetIconFamilyData( iconFamily
, 'PICT' , (Handle
) pic
) ;
572 // transform into IconRef
574 // cleaner version existing from 10.3 upwards
575 HLock((Handle
) iconFamily
);
576 OSStatus err
= GetIconRefFromIconFamilyPtr( *iconFamily
, GetHandleSize((Handle
) iconFamily
), &m_iconRef
);
577 HUnlock((Handle
) iconFamily
);
578 DisposeHandle( (Handle
) iconFamily
) ;
580 wxCHECK_MSG( err
== noErr
, NULL
, wxT("Error when constructing icon ref") );
586 PicHandle
wxBitmapRefData::GetPictHandle()
588 if ( m_pictHandle
== NULL
)
591 GraphicsExportComponent exporter
= 0;
592 OSStatus err
= OpenADefaultComponent(GraphicsExporterComponentType
, kQTFileTypePicture
, &exporter
);
595 m_pictHandle
= (PicHandle
) NewHandle(0);
598 // QT does not correctly export the mask
599 // TODO if we get around to it create a synthetic PICT with the CopyBits and Mask commands
600 CGImageRef imageRef
= CreateCGImage();
601 err
= GraphicsExportSetInputCGImage( exporter
, imageRef
);
602 err
= GraphicsExportSetOutputHandle(exporter
, (Handle
)m_pictHandle
);
603 err
= GraphicsExportDoExport(exporter
, NULL
);
604 CGImageRelease( imageRef
);
606 size_t handleSize
= GetHandleSize( (Handle
) m_pictHandle
);
607 // the 512 bytes header is only needed for pict files, but not in memory
608 if ( handleSize
>= 512 )
610 memmove( *m_pictHandle
, (char*)(*m_pictHandle
)+512, handleSize
- 512 );
611 SetHandleSize( (Handle
) m_pictHandle
, handleSize
- 512 );
614 CloseComponent( exporter
);
619 return m_pictHandle
;
623 CGImageRef
wxBitmapRefData::CreateCGImage() const
626 wxASSERT( m_rawAccessCount
>= 0 ) ;
628 if ( m_rawAccessCount
> 0 || m_cgImageRef
== NULL
)
630 if ( m_depth
!= 1 && m_bitmapMask
== NULL
)
634 CGImageRef tempImage
= CGBitmapContextCreateImage( m_hBitmap
);
635 CGImageRef tempMask
= CGBitmapContextCreateImage((CGContextRef
) m_bitmapMask
->GetHBITMAP() );
636 image
= CGImageCreateWithMask( tempImage
, tempMask
);
637 CGImageRelease(tempMask
);
638 CGImageRelease(tempImage
);
641 image
= CGBitmapContextCreateImage( m_hBitmap
);
645 size_t imageSize
= m_height
* m_bytesPerRow
;
646 void * dataBuffer
= m_memBuf
.GetData() ;
649 CGImageAlphaInfo alphaInfo
= kCGImageAlphaNoneSkipFirst
;
650 wxMemoryBuffer membuf
;
654 alphaInfo
= kCGImageAlphaFirst
;
655 unsigned char *destalphastart
= (unsigned char*) membuf
.GetWriteBuf( imageSize
) ;
656 memcpy( destalphastart
, dataBuffer
, imageSize
) ;
657 unsigned char *sourcemaskstart
= (unsigned char *) m_bitmapMask
->GetRawAccess() ;
658 int maskrowbytes
= m_bitmapMask
->GetBytesPerRow() ;
659 for ( int y
= 0 ; y
< h
; ++y
, destalphastart
+= m_bytesPerRow
, sourcemaskstart
+= maskrowbytes
)
661 unsigned char *sourcemask
= sourcemaskstart
;
662 unsigned char *destalpha
= destalphastart
;
663 for ( int x
= 0 ; x
< w
; ++x
, sourcemask
+= kMaskBytesPerPixel
, destalpha
+= 4 )
665 *destalpha
= 0xFF - *sourcemask
;
668 membuf
.UngetWriteBuf( imageSize
);
674 #if wxMAC_USE_PREMULTIPLIED_ALPHA
675 alphaInfo
= kCGImageAlphaPremultipliedFirst
;
677 alphaInfo
= kCGImageAlphaFirst
;
684 CGDataProviderRef dataProvider
= NULL
;
687 // TODO CHECK ALIGNMENT
688 wxMemoryBuffer maskBuf
;
689 unsigned char * maskBufData
= (unsigned char*) maskBuf
.GetWriteBuf( m_width
* m_height
);
690 unsigned char * bufData
= (unsigned char *) membuf
.GetData() ;
691 // copy one color component
693 for( int y
= 0 ; y
< m_height
; bufData
+= m_bytesPerRow
, ++y
)
695 unsigned char *bufDataIter
= bufData
+3;
696 for ( int x
= 0 ; x
< m_width
; bufDataIter
+= 4, ++x
, ++i
)
698 maskBufData
[i
] = *bufDataIter
;
701 maskBuf
.UngetWriteBuf( m_width
* m_height
);
704 wxMacCGDataProviderCreateWithMemoryBuffer( maskBuf
);
706 image
= ::CGImageMaskCreate( w
, h
, 8, 8, m_width
, dataProvider
, NULL
, false );
710 CGColorSpaceRef colorSpace
= wxMacGetGenericRGBColorSpace();
711 dataProvider
= wxMacCGDataProviderCreateWithMemoryBuffer( membuf
);
714 w
, h
, 8 , 32 , m_bytesPerRow
, colorSpace
, alphaInfo
,
715 dataProvider
, NULL
, false , kCGRenderingIntentDefault
);
717 CGDataProviderRelease( dataProvider
);
722 image
= m_cgImageRef
;
723 CGImageRetain( image
) ;
726 if ( m_rawAccessCount
== 0 && m_cgImageRef
== NULL
)
728 // we keep it for later use
729 m_cgImageRef
= image
;
730 CGImageRetain( image
) ;
736 CGContextRef
wxBitmapRefData::GetBitmapContext() const
741 void wxBitmapRefData::Free()
743 wxASSERT_MSG( m_rawAccessCount
== 0 , wxT("Bitmap still selected when destroyed") ) ;
747 CGImageRelease( m_cgImageRef
) ;
748 m_cgImageRef
= NULL
;
750 #ifndef __WXOSX_IPHONE__
753 ReleaseIconRef( m_iconRef
) ;
760 KillPicture( m_pictHandle
) ;
761 m_pictHandle
= NULL
;
767 CGContextRelease(m_hBitmap
);
778 wxBitmapRefData::~wxBitmapRefData()
783 bool wxBitmap::CopyFromIcon(const wxIcon
& icon
)
785 bool created
= false ;
786 int w
= icon
.GetWidth() ;
787 int h
= icon
.GetHeight() ;
789 Create( icon
.GetWidth() , icon
.GetHeight() ) ;
790 #ifndef __WXOSX_IPHONE__
791 if ( w
== h
&& ( w
== 16 || w
== 32 || w
== 48 || w
== 128 ) )
793 IconFamilyHandle iconFamily
= NULL
;
794 Handle imagehandle
= NewHandle( 0 ) ;
795 Handle maskhandle
= NewHandle( 0 ) ;
799 IconSelectorValue selector
= 0 ;
804 dataType
= kThumbnail32BitData
;
805 maskType
= kThumbnail8BitMask
;
806 selector
= kSelectorAllAvailableData
;
810 dataType
= kHuge32BitData
;
811 maskType
= kHuge8BitMask
;
812 selector
= kSelectorHuge32Bit
| kSelectorHuge8BitMask
;
816 dataType
= kLarge32BitData
;
817 maskType
= kLarge8BitMask
;
818 selector
= kSelectorLarge32Bit
| kSelectorLarge8BitMask
;
822 dataType
= kSmall32BitData
;
823 maskType
= kSmall8BitMask
;
824 selector
= kSelectorSmall32Bit
| kSelectorSmall8BitMask
;
831 OSStatus err
= IconRefToIconFamily( MAC_WXHICON(icon
.GetHICON()) , selector
, &iconFamily
) ;
833 err
= GetIconFamilyData( iconFamily
, dataType
, imagehandle
) ;
834 err
= GetIconFamilyData( iconFamily
, maskType
, maskhandle
) ;
835 size_t imagehandlesize
= GetHandleSize( imagehandle
) ;
836 size_t maskhandlesize
= GetHandleSize( maskhandle
) ;
838 if ( imagehandlesize
!= 0 && maskhandlesize
!= 0 )
840 wxASSERT( GetHandleSize( imagehandle
) == w
* 4 * h
) ;
841 wxASSERT( GetHandleSize( maskhandle
) == w
* h
) ;
845 unsigned char *source
= (unsigned char *) *imagehandle
;
846 unsigned char *sourcemask
= (unsigned char *) *maskhandle
;
847 unsigned char* destination
= (unsigned char*) BeginRawAccess() ;
849 for ( int y
= 0 ; y
< h
; ++y
)
851 for ( int x
= 0 ; x
< w
; ++x
)
853 unsigned char a
= *sourcemask
++;
856 #if wxMAC_USE_PREMULTIPLIED_ALPHA
857 *destination
++ = ( (*source
++) * a
+ 127 ) / 255;
858 *destination
++ = ( (*source
++) * a
+ 127 ) / 255;
859 *destination
++ = ( (*source
++) * a
+ 127 ) / 255;
861 *destination
++ = *source
++ ;
862 *destination
++ = *source
++ ;
863 *destination
++ = *source
++ ;
869 DisposeHandle( imagehandle
) ;
870 DisposeHandle( maskhandle
) ;
874 DisposeHandle( (Handle
) iconFamily
) ;
880 dc
.SelectObject( *this ) ;
881 dc
.DrawIcon( icon
, 0 , 0 ) ;
882 dc
.SelectObject( wxNullBitmap
) ;
892 wxBitmap::~wxBitmap()
896 wxBitmap::wxBitmap(const char bits
[], int the_width
, int the_height
, int no_bits
)
898 wxBitmapRefData
* bitmapRefData
;
900 m_refData
= bitmapRefData
= new wxBitmapRefData( the_width
, the_height
, no_bits
) ;
902 if (bitmapRefData
->IsOk())
906 int linesize
= ( the_width
/ (sizeof(unsigned char) * 8)) ;
907 if ( the_width
% (sizeof(unsigned char) * 8) )
908 linesize
+= sizeof(unsigned char);
910 unsigned char* linestart
= (unsigned char*) bits
;
911 unsigned char* destptr
= (unsigned char*) BeginRawAccess() ;
913 for ( int y
= 0 ; y
< the_height
; ++y
, linestart
+= linesize
, destptr
+= M_BITMAPDATA
->GetBytesPerRow() )
915 unsigned char* destination
= destptr
;
916 int index
, bit
, mask
;
918 for ( int x
= 0 ; x
< the_width
; ++x
)
924 if ( linestart
[index
] & mask
)
926 *destination
++ = 0xFF ;
933 *destination
++ = 0xFF ;
934 *destination
++ = 0xFF ;
935 *destination
++ = 0xFF ;
936 *destination
++ = 0xFF ;
945 wxFAIL_MSG(wxT("multicolor BITMAPs not yet implemented"));
947 } /* bitmapRefData->IsOk() */
950 wxBitmap::wxBitmap(int w
, int h
, int d
)
952 (void)Create(w
, h
, d
);
955 wxBitmap::wxBitmap(const void* data
, wxBitmapType type
, int width
, int height
, int depth
)
957 (void) Create(data
, type
, width
, height
, depth
);
960 wxBitmap::wxBitmap(const wxString
& filename
, wxBitmapType type
)
962 LoadFile(filename
, type
);
965 wxGDIRefData
* wxBitmap::CreateGDIRefData() const
967 return new wxBitmapRefData
;
970 wxGDIRefData
* wxBitmap::CloneGDIRefData(const wxGDIRefData
* data
) const
972 return new wxBitmapRefData(*wx_static_cast(const wxBitmapRefData
*, data
));
975 void * wxBitmap::GetRawAccess() const
977 wxCHECK_MSG( Ok() , NULL
, wxT("invalid bitmap") ) ;
979 return M_BITMAPDATA
->GetRawAccess() ;
982 void * wxBitmap::BeginRawAccess()
984 wxCHECK_MSG( Ok() , NULL
, wxT("invalid bitmap") ) ;
986 return M_BITMAPDATA
->BeginRawAccess() ;
989 void wxBitmap::EndRawAccess()
991 wxCHECK_RET( Ok() , wxT("invalid bitmap") ) ;
993 M_BITMAPDATA
->EndRawAccess() ;
996 CGImageRef
wxBitmap::CreateCGImage() const
998 wxCHECK_MSG( Ok(), NULL
, wxT("invalid bitmap") ) ;
1000 return M_BITMAPDATA
->CreateCGImage() ;
1003 #ifndef __WXOSX_IPHONE__
1004 IconRef
wxBitmap::GetIconRef() const
1006 wxCHECK_MSG( Ok(), NULL
, wxT("invalid bitmap") ) ;
1008 return M_BITMAPDATA
->GetIconRef() ;
1011 IconRef
wxBitmap::CreateIconRef() const
1013 IconRef icon
= GetIconRef();
1014 verify_noerr( AcquireIconRef(icon
) );
1019 wxBitmap
wxBitmap::GetSubBitmap(const wxRect
&rect
) const
1021 wxCHECK_MSG( Ok() &&
1022 (rect
.x
>= 0) && (rect
.y
>= 0) &&
1023 (rect
.x
+rect
.width
<= GetWidth()) &&
1024 (rect
.y
+rect
.height
<= GetHeight()),
1025 wxNullBitmap
, wxT("invalid bitmap or bitmap region") );
1027 wxBitmap
ret( rect
.width
, rect
.height
, GetDepth() );
1028 wxASSERT_MSG( ret
.Ok(), wxT("GetSubBitmap error") );
1030 int destwidth
= rect
.width
;
1031 int destheight
= rect
.height
;
1034 unsigned char *sourcedata
= (unsigned char*) GetRawAccess() ;
1035 unsigned char *destdata
= (unsigned char*) ret
.BeginRawAccess() ;
1036 wxASSERT( (sourcedata
!= NULL
) && (destdata
!= NULL
) ) ;
1038 int sourcelinesize
= GetBitmapData()->GetBytesPerRow() ;
1039 int destlinesize
= ret
.GetBitmapData()->GetBytesPerRow() ;
1040 unsigned char *source
= sourcedata
+ rect
.x
* 4 + rect
.y
* sourcelinesize
;
1041 unsigned char *dest
= destdata
;
1043 for (int yy
= 0; yy
< destheight
; ++yy
, source
+= sourcelinesize
, dest
+= destlinesize
)
1045 memcpy( dest
, source
, destlinesize
) ;
1049 ret
.EndRawAccess() ;
1051 if ( M_BITMAPDATA
->m_bitmapMask
)
1053 wxMemoryBuffer maskbuf
;
1054 int rowBytes
= GetBestBytesPerRow( destwidth
* kMaskBytesPerPixel
);
1055 size_t maskbufsize
= rowBytes
* destheight
;
1057 int sourcelinesize
= M_BITMAPDATA
->m_bitmapMask
->GetBytesPerRow() ;
1058 int destlinesize
= rowBytes
;
1060 unsigned char *source
= (unsigned char *) M_BITMAPDATA
->m_bitmapMask
->GetRawAccess() ;
1061 unsigned char *destdata
= (unsigned char * ) maskbuf
.GetWriteBuf( maskbufsize
) ;
1062 wxASSERT( (source
!= NULL
) && (destdata
!= NULL
) ) ;
1064 source
+= rect
.x
* kMaskBytesPerPixel
+ rect
.y
* sourcelinesize
;
1065 unsigned char *dest
= destdata
;
1067 for (int yy
= 0; yy
< destheight
; ++yy
, source
+= sourcelinesize
, dest
+= destlinesize
)
1069 memcpy( dest
, source
, destlinesize
) ;
1072 maskbuf
.UngetWriteBuf( maskbufsize
) ;
1073 ret
.SetMask( new wxMask( maskbuf
, destwidth
, destheight
, rowBytes
) ) ;
1075 else if ( HasAlpha() )
1081 bool wxBitmap::Create(int w
, int h
, int d
)
1086 d
= wxDisplayDepth() ;
1088 m_refData
= new wxBitmapRefData( w
, h
, d
);
1090 return M_BITMAPDATA
->IsOk() ;
1093 bool wxBitmap::LoadFile(const wxString
& filename
, wxBitmapType type
)
1097 wxBitmapHandler
*handler
= FindHandler(type
);
1101 m_refData
= new wxBitmapRefData
;
1103 return handler
->LoadFile(this, filename
, type
, -1, -1);
1108 wxImage
loadimage(filename
, type
);
1118 wxLogWarning(wxT("no bitmap handler for type %d defined."), type
);
1123 bool wxBitmap::Create(const void* data
, wxBitmapType type
, int width
, int height
, int depth
)
1127 m_refData
= new wxBitmapRefData
;
1129 wxBitmapHandler
*handler
= FindHandler(type
);
1131 if ( handler
== NULL
)
1133 wxLogWarning(wxT("no bitmap handler for type %d defined."), type
);
1138 return handler
->Create(this, data
, type
, width
, height
, depth
);
1143 wxBitmap::wxBitmap(const wxImage
& image
, int depth
)
1145 wxCHECK_RET( image
.Ok(), wxT("invalid image") );
1147 // width and height of the device-dependent bitmap
1148 int width
= image
.GetWidth();
1149 int height
= image
.GetHeight();
1151 wxBitmapRefData
* bitmapRefData
;
1153 m_refData
= bitmapRefData
= new wxBitmapRefData( width
, height
, depth
) ;
1155 if ( bitmapRefData
->IsOk())
1159 bool hasAlpha
= false ;
1161 if ( image
.HasMask() )
1163 // takes precedence, don't mix with alpha info
1167 hasAlpha
= image
.HasAlpha() ;
1173 unsigned char* destinationstart
= (unsigned char*) BeginRawAccess() ;
1174 register unsigned char* data
= image
.GetData();
1175 if ( destinationstart
!= NULL
&& data
!= NULL
)
1177 const unsigned char *alpha
= hasAlpha
? image
.GetAlpha() : NULL
;
1178 for (int y
= 0; y
< height
; destinationstart
+= M_BITMAPDATA
->GetBytesPerRow(), y
++)
1180 unsigned char * destination
= destinationstart
;
1181 for (int x
= 0; x
< width
; x
++)
1185 const unsigned char a
= *alpha
++;
1186 *destination
++ = a
;
1188 #if wxMAC_USE_PREMULTIPLIED_ALPHA
1189 *destination
++ = ((*data
++) * a
+ 127) / 255 ;
1190 *destination
++ = ((*data
++) * a
+ 127) / 255 ;
1191 *destination
++ = ((*data
++) * a
+ 127) / 255 ;
1193 *destination
++ = *data
++ ;
1194 *destination
++ = *data
++ ;
1195 *destination
++ = *data
++ ;
1200 *destination
++ = 0xFF ;
1201 *destination
++ = *data
++ ;
1202 *destination
++ = *data
++ ;
1203 *destination
++ = *data
++ ;
1210 if ( image
.HasMask() )
1211 SetMask( new wxMask( *this , wxColour( image
.GetMaskRed() , image
.GetMaskGreen() , image
.GetMaskBlue() ) ) ) ;
1212 } /* bitmapRefData->IsOk() */
1215 wxImage
wxBitmap::ConvertToImage() const
1219 wxCHECK_MSG( Ok(), wxNullImage
, wxT("invalid bitmap") );
1221 // create an wxImage object
1222 int width
= GetWidth();
1223 int height
= GetHeight();
1224 image
.Create( width
, height
);
1226 unsigned char *data
= image
.GetData();
1227 wxCHECK_MSG( data
, wxNullImage
, wxT("Could not allocate data for image") );
1229 unsigned char* sourcestart
= (unsigned char*) GetRawAccess() ;
1231 bool hasAlpha
= false ;
1232 bool hasMask
= false ;
1233 int maskBytesPerRow
= 0 ;
1234 unsigned char *alpha
= NULL
;
1235 unsigned char *mask
= NULL
;
1243 mask
= (unsigned char*) GetMask()->GetRawAccess() ;
1244 maskBytesPerRow
= GetMask()->GetBytesPerRow() ;
1250 alpha
= image
.GetAlpha() ;
1255 // The following masking algorithm is the same as well in msw/gtk:
1256 // the colour used as transparent one in wxImage and the one it is
1257 // replaced with when it actually occurs in the bitmap
1258 static const int MASK_RED
= 1;
1259 static const int MASK_GREEN
= 2;
1260 static const int MASK_BLUE
= 3;
1261 static const int MASK_BLUE_REPLACEMENT
= 2;
1263 for (int yy
= 0; yy
< height
; yy
++ , sourcestart
+= M_BITMAPDATA
->GetBytesPerRow() , mask
+= maskBytesPerRow
)
1265 unsigned char * maskp
= mask
;
1266 unsigned char * source
= sourcestart
;
1267 unsigned char a
, r
, g
, b
;
1270 for (int xx
= 0; xx
< width
; xx
++)
1272 color
= *((long*) source
) ;
1273 #ifdef WORDS_BIGENDIAN
1274 a
= ((color
&0xFF000000) >> 24) ;
1275 r
= ((color
&0x00FF0000) >> 16) ;
1276 g
= ((color
&0x0000FF00) >> 8) ;
1277 b
= (color
&0x000000FF);
1279 b
= ((color
&0xFF000000) >> 24) ;
1280 g
= ((color
&0x00FF0000) >> 16) ;
1281 r
= ((color
&0x0000FF00) >> 8) ;
1282 a
= (color
&0x000000FF);
1286 if ( *maskp
++ == 0xFF )
1292 else if ( r
== MASK_RED
&& g
== MASK_GREEN
&& b
== MASK_BLUE
)
1293 b
= MASK_BLUE_REPLACEMENT
;
1295 else if ( hasAlpha
)
1298 #if wxMAC_USE_PREMULTIPLIED_ALPHA
1299 // this must be non-premultiplied data
1300 if ( a
!= 0xFF && a
!= 0 )
1310 data
[index
+ 1] = g
;
1311 data
[index
+ 2] = b
;
1319 image
.SetMaskColour( MASK_RED
, MASK_GREEN
, MASK_BLUE
);
1324 #endif //wxUSE_IMAGE
1326 bool wxBitmap::SaveFile( const wxString
& filename
,
1327 wxBitmapType type
, const wxPalette
*palette
) const
1329 bool success
= false;
1330 wxBitmapHandler
*handler
= FindHandler(type
);
1334 success
= handler
->SaveFile(this, filename
, type
, palette
);
1339 wxImage image
= ConvertToImage();
1340 success
= image
.SaveFile(filename
, type
);
1342 wxLogWarning(wxT("no bitmap handler for type %d defined."), type
);
1349 int wxBitmap::GetHeight() const
1351 wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
1353 return M_BITMAPDATA
->GetHeight();
1356 int wxBitmap::GetWidth() const
1358 wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
1360 return M_BITMAPDATA
->GetWidth() ;
1363 int wxBitmap::GetDepth() const
1365 wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
1367 return M_BITMAPDATA
->GetDepth();
1370 wxMask
*wxBitmap::GetMask() const
1372 wxCHECK_MSG( Ok(), (wxMask
*) NULL
, wxT("invalid bitmap") );
1374 return M_BITMAPDATA
->m_bitmapMask
;
1377 bool wxBitmap::HasAlpha() const
1379 wxCHECK_MSG( Ok(), false , wxT("invalid bitmap") );
1381 return M_BITMAPDATA
->HasAlpha() ;
1384 void wxBitmap::SetWidth(int w
)
1387 M_BITMAPDATA
->SetWidth(w
);
1390 void wxBitmap::SetHeight(int h
)
1393 M_BITMAPDATA
->SetHeight(h
);
1396 void wxBitmap::SetDepth(int d
)
1399 M_BITMAPDATA
->SetDepth(d
);
1402 void wxBitmap::SetOk(bool isOk
)
1405 M_BITMAPDATA
->SetOk(isOk
);
1409 wxPalette
*wxBitmap::GetPalette() const
1411 wxCHECK_MSG( Ok(), NULL
, wxT("Invalid bitmap GetPalette()") );
1413 return &M_BITMAPDATA
->m_bitmapPalette
;
1416 void wxBitmap::SetPalette(const wxPalette
& palette
)
1419 M_BITMAPDATA
->m_bitmapPalette
= palette
;
1421 #endif // wxUSE_PALETTE
1423 void wxBitmap::SetMask(wxMask
*mask
)
1426 // Remove existing mask if there is one.
1427 delete M_BITMAPDATA
->m_bitmapMask
;
1429 M_BITMAPDATA
->m_bitmapMask
= mask
;
1432 WXHBITMAP
wxBitmap::GetHBITMAP(WXHBITMAP
* mask
) const
1436 return WXHBITMAP(M_BITMAPDATA
->GetBitmapContext());
1439 // ----------------------------------------------------------------------------
1441 // ----------------------------------------------------------------------------
1448 wxMask::wxMask(const wxMask
&tocopy
)
1452 m_bytesPerRow
= tocopy
.m_bytesPerRow
;
1453 m_width
= tocopy
.m_width
;
1454 m_height
= tocopy
.m_height
;
1456 size_t size
= m_bytesPerRow
* m_height
;
1457 unsigned char* dest
= (unsigned char*)m_memBuf
.GetWriteBuf( size
);
1458 unsigned char* source
= (unsigned char*)tocopy
.m_memBuf
.GetData();
1459 memcpy( dest
, source
, size
);
1460 m_memBuf
.UngetWriteBuf( size
) ;
1464 // Construct a mask from a bitmap and a colour indicating
1465 // the transparent area
1466 wxMask::wxMask( const wxBitmap
& bitmap
, const wxColour
& colour
)
1469 Create( bitmap
, colour
);
1472 // Construct a mask from a mono bitmap (copies the bitmap).
1473 wxMask::wxMask( const wxBitmap
& bitmap
)
1479 // Construct a mask from a mono bitmap (copies the bitmap).
1481 wxMask::wxMask( const wxMemoryBuffer
& data
, int width
, int height
, int bytesPerRow
)
1484 Create( data
, width
, height
, bytesPerRow
);
1491 CGContextRelease( (CGContextRef
) m_maskBitmap
);
1492 m_maskBitmap
= NULL
;
1498 m_width
= m_height
= m_bytesPerRow
= 0 ;
1499 m_maskBitmap
= NULL
;
1502 void *wxMask::GetRawAccess() const
1504 return m_memBuf
.GetData() ;
1507 // The default ColorTable for k8IndexedGrayPixelFormat in Intel appears to be broken, so we'll use an non-indexed
1508 // bitmap mask instead; in order to keep the code simple, the change applies to PowerPC implementations as well
1510 void wxMask::RealizeNative()
1514 CGContextRelease( (CGContextRef
) m_maskBitmap
);
1515 m_maskBitmap
= NULL
;
1518 CGColorSpaceRef colorspace
= CGColorSpaceCreateDeviceGray();
1519 // from MouseTracking sample :
1520 // Ironically, due to a bug in CGImageCreateWithMask, you cannot use
1521 // CGColorSpaceCreateWithName(kCGColorSpaceGenericGray) at this point!
1523 m_maskBitmap
= CGBitmapContextCreate((char*) m_memBuf
.GetData(), m_width
, m_height
, 8, m_bytesPerRow
, colorspace
,
1524 kCGImageAlphaNone
);
1525 CGColorSpaceRelease( colorspace
);
1526 wxASSERT_MSG( m_maskBitmap
, wxT("Unable to create CGBitmapContext context") ) ;
1529 // Create a mask from a mono bitmap (copies the bitmap).
1531 bool wxMask::Create(const wxMemoryBuffer
& data
,int width
, int height
, int bytesPerRow
)
1536 m_bytesPerRow
= bytesPerRow
;
1538 wxASSERT( data
.GetDataLen() == (size_t)(height
* bytesPerRow
) ) ;
1545 // Create a mask from a mono bitmap (copies the bitmap).
1546 bool wxMask::Create(const wxBitmap
& bitmap
)
1548 m_width
= bitmap
.GetWidth() ;
1549 m_height
= bitmap
.GetHeight() ;
1550 m_bytesPerRow
= GetBestBytesPerRow( m_width
* kMaskBytesPerPixel
) ;
1552 size_t size
= m_bytesPerRow
* m_height
;
1553 unsigned char * destdatabase
= (unsigned char*) m_memBuf
.GetWriteBuf( size
) ;
1554 wxASSERT( destdatabase
!= NULL
) ;
1556 memset( destdatabase
, 0 , size
) ;
1557 unsigned char * srcdata
= (unsigned char*) bitmap
.GetRawAccess() ;
1559 for ( int y
= 0 ; y
< m_height
; ++y
, destdatabase
+= m_bytesPerRow
)
1561 unsigned char *destdata
= destdatabase
;
1562 unsigned char r
, g
, b
;
1564 for ( int x
= 0 ; x
< m_width
; ++x
)
1571 if ( ( r
+ g
+ b
) > 0x10 )
1572 *destdata
++ = 0xFF ;
1574 *destdata
++ = 0x00 ;
1578 m_memBuf
.UngetWriteBuf( size
) ;
1584 // Create a mask from a bitmap and a colour indicating
1585 // the transparent area
1586 bool wxMask::Create(const wxBitmap
& bitmap
, const wxColour
& colour
)
1588 m_width
= bitmap
.GetWidth() ;
1589 m_height
= bitmap
.GetHeight() ;
1590 m_bytesPerRow
= GetBestBytesPerRow( m_width
* kMaskBytesPerPixel
) ;
1592 size_t size
= m_bytesPerRow
* m_height
;
1593 unsigned char * destdatabase
= (unsigned char*) m_memBuf
.GetWriteBuf( size
) ;
1594 wxASSERT( destdatabase
!= NULL
) ;
1596 memset( destdatabase
, 0 , size
) ;
1597 unsigned char * srcdatabase
= (unsigned char*) bitmap
.GetRawAccess() ;
1598 size_t sourceBytesRow
= bitmap
.GetBitmapData()->GetBytesPerRow();
1600 for ( int y
= 0 ; y
< m_height
; ++y
, srcdatabase
+= sourceBytesRow
, destdatabase
+= m_bytesPerRow
)
1602 unsigned char *srcdata
= srcdatabase
;
1603 unsigned char *destdata
= destdatabase
;
1604 unsigned char r
, g
, b
;
1606 for ( int x
= 0 ; x
< m_width
; ++x
)
1613 if ( colour
== wxColour( r
, g
, b
) )
1614 *destdata
++ = 0xFF ;
1616 *destdata
++ = 0x00 ;
1620 m_memBuf
.UngetWriteBuf( size
) ;
1626 WXHBITMAP
wxMask::GetHBITMAP() const
1628 return m_maskBitmap
;
1631 // ----------------------------------------------------------------------------
1632 // Standard Handlers
1633 // ----------------------------------------------------------------------------
1635 #if !defined( __LP64__ ) && !defined(__WXOSX_IPHONE__)
1637 class WXDLLEXPORT wxPICTResourceHandler
: public wxBitmapHandler
1639 DECLARE_DYNAMIC_CLASS(wxPICTResourceHandler
)
1642 inline wxPICTResourceHandler()
1644 SetName(wxT("Macintosh Pict resource"));
1645 SetExtension(wxEmptyString
);
1646 SetType(wxBITMAP_TYPE_PICT_RESOURCE
);
1649 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
1650 int desiredWidth
, int desiredHeight
);
1653 IMPLEMENT_DYNAMIC_CLASS(wxPICTResourceHandler
, wxBitmapHandler
)
1656 bool wxPICTResourceHandler::LoadFile(wxBitmap
*bitmap
,
1657 const wxString
& name
,
1658 long WXUNUSED(flags
),
1659 int WXUNUSED(desiredWidth
),
1660 int WXUNUSED(desiredHeight
))
1664 wxMacStringToPascal( name
, theName
) ;
1666 PicHandle thePict
= (PicHandle
) GetNamedResource( 'PICT' , theName
) ;
1671 mf
.SetPICT( thePict
) ;
1672 bitmap
->Create( mf
.GetWidth() , mf
.GetHeight() ) ;
1674 dc
.SelectObject( *bitmap
) ;
1676 dc
.SelectObject( wxNullBitmap
) ;
1686 void wxBitmap::InitStandardHandlers()
1688 #if !defined( __LP64__ ) && !defined(__WXOSX_IPHONE__)
1689 AddHandler( new wxPICTResourceHandler
) ;
1691 AddHandler( new wxICONResourceHandler
) ;
1694 // ----------------------------------------------------------------------------
1695 // raw bitmap access support
1696 // ----------------------------------------------------------------------------
1698 void *wxBitmap::GetRawData(wxPixelDataBase
& data
, int WXUNUSED(bpp
))
1701 // no bitmap, no data (raw or otherwise)
1704 data
.m_width
= GetWidth() ;
1705 data
.m_height
= GetHeight() ;
1706 data
.m_stride
= GetBitmapData()->GetBytesPerRow() ;
1708 return BeginRawAccess() ;
1711 void wxBitmap::UngetRawData(wxPixelDataBase
& WXUNUSED(dataBase
))
1716 void wxBitmap::UseAlpha()
1718 // remember that we are using alpha channel:
1719 // we'll need to create a proper mask in UngetRawData()
1720 M_BITMAPDATA
->UseAlpha( true );