1 /////////////////////////////////////////////////////////////////////////////
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "bitmap.h"
19 #include "wx/palette.h"
20 #include "wx/bitmap.h"
33 #if !USE_SHARED_LIBRARIES
34 IMPLEMENT_DYNAMIC_CLASS(wxBitmap
, wxGDIObject
)
35 IMPLEMENT_DYNAMIC_CLASS(wxMask
, wxObject
)
39 #include <QD/PictUtils.h>
41 #include <PictUtils.h>
44 CTabHandle
wxMacCreateColorTable( int numColors
)
46 CTabHandle newColors
; /* Handle to the new color table */
48 /* Allocate memory for the color table */
49 newColors
= (CTabHandle
)NewHandleClear( sizeof (ColorTable
) +
50 sizeof (ColorSpec
) * (numColors
- 1) );
53 /* Initialize the fields */
54 (**newColors
).ctSeed
= GetCTSeed();
55 (**newColors
).ctFlags
= 0;
56 (**newColors
).ctSize
= numColors
- 1;
57 /* Initialize the table of colors */
62 void wxMacDestroyColorTable( CTabHandle colors
)
64 DisposeHandle( (Handle
) colors
) ;
67 void wxMacSetColorTableEntry( CTabHandle newColors
, int index
, int red
, int green
, int blue
)
69 (**newColors
).ctTable
[index
].value
= index
;
70 (**newColors
).ctTable
[index
].rgb
.red
= 0 ;// someRedValue;
71 (**newColors
).ctTable
[index
].rgb
.green
= 0 ; // someGreenValue;
72 (**newColors
).ctTable
[index
].rgb
.blue
= 0 ; // someBlueValue;
75 GWorldPtr
wxMacCreateGWorld( int width
, int height
, int depth
)
79 Rect rect
= { 0 , 0 , height
, width
} ;
83 depth
= wxDisplayDepth() ;
86 err
= NewGWorld( &port
, depth
, &rect
, NULL
, NULL
, 0 ) ;
94 void wxMacDestroyGWorld( GWorldPtr gw
)
100 wxBitmapRefData::wxBitmapRefData()
111 m_bitmapType
= kMacBitmapTypeUnknownType
;
114 wxBitmapRefData::~wxBitmapRefData()
116 switch (m_bitmapType
)
118 case kMacBitmapTypePict
:
122 KillPicture( m_hPict
) ;
127 case kMacBitmapTypeGrafWorld
:
131 wxMacDestroyGWorld( m_hBitmap
) ;
148 wxList
wxBitmap::sm_handlers
;
154 if ( wxTheBitmapList
)
155 wxTheBitmapList
->AddBitmap(this);
158 wxBitmap::~wxBitmap()
161 wxTheBitmapList
->DeleteObject(this);
164 wxBitmap::wxBitmap(const char bits
[], int the_width
, int the_height
, int no_bits
)
166 m_refData
= new wxBitmapRefData
;
168 M_BITMAPDATA
->m_width
= the_width
;
169 M_BITMAPDATA
->m_height
= the_height
;
170 M_BITMAPDATA
->m_depth
= no_bits
;
171 M_BITMAPDATA
->m_numColors
= 0;
174 M_BITMAPDATA
->m_bitmapType
= kMacBitmapTypeGrafWorld
;
175 M_BITMAPDATA
->m_hBitmap
= wxMacCreateGWorld( the_width
, the_height
, no_bits
) ;
176 M_BITMAPDATA
->m_ok
= (M_BITMAPDATA
->m_hBitmap
!= NULL
) ;
179 GDHandle origDevice
;
181 GetGWorld( &origPort
, &origDevice
) ;
182 SetGWorld( M_BITMAPDATA
->m_hBitmap
, NULL
) ;
183 LockPixels( GetGWorldPixMap( (CGrafPtr
) M_BITMAPDATA
->m_hBitmap
) ) ;
185 // bits is a word aligned array
187 unsigned char* linestart
= (unsigned char*) bits
;
188 int linesize
= ( the_width
/ 16 ) * 2 ;
189 if ( the_width
% 16 )
194 RGBColor colors
[2] = {
195 { 0xFFFF , 0xFFFF , 0xFFFF } ,
199 for ( int y
= 0 ; y
< the_height
; ++y
, linestart
+= linesize
)
201 for ( int x
= 0 ; x
< the_width
; ++x
)
205 int mask
= 1 << bit
;
206 if ( linestart
[index
] & mask
)
208 SetCPixel( x
, y
, &colors
[1] ) ;
212 SetCPixel( x
, y
, &colors
[0] ) ;
217 UnlockPixels( GetGWorldPixMap( (CGrafPtr
) M_BITMAPDATA
->m_hBitmap
) ) ;
219 SetGWorld( origPort
, origDevice
) ;
223 wxFAIL_MSG(wxT("multicolor BITMAPs not yet implemented"));
226 if ( wxTheBitmapList
)
227 wxTheBitmapList
->AddBitmap(this);
230 wxBitmap::wxBitmap(int w
, int h
, int d
)
232 (void)Create(w
, h
, d
);
234 if ( wxTheBitmapList
)
235 wxTheBitmapList
->AddBitmap(this);
238 wxBitmap::wxBitmap(void *data
, long type
, int width
, int height
, int depth
)
240 (void) Create(data
, type
, width
, height
, depth
);
242 if ( wxTheBitmapList
)
243 wxTheBitmapList
->AddBitmap(this);
246 wxBitmap::wxBitmap(const wxString
& filename
, long type
)
248 LoadFile(filename
, (int)type
);
250 if ( wxTheBitmapList
)
251 wxTheBitmapList
->AddBitmap(this);
254 wxBitmap::wxBitmap(const char **data
)
256 (void) Create((void *)data
, wxBITMAP_TYPE_XPM_DATA
, 0, 0, 0);
259 wxBitmap::wxBitmap(char **data
)
261 (void) Create((void *)data
, wxBITMAP_TYPE_XPM_DATA
, 0, 0, 0);
264 bool wxBitmap::Create(int w
, int h
, int d
)
268 m_refData
= new wxBitmapRefData
;
270 M_BITMAPDATA
->m_width
= w
;
271 M_BITMAPDATA
->m_height
= h
;
272 M_BITMAPDATA
->m_depth
= d
;
274 M_BITMAPDATA
->m_bitmapType
= kMacBitmapTypeGrafWorld
;
275 M_BITMAPDATA
->m_hBitmap
= wxMacCreateGWorld( w
, h
, d
) ;
276 M_BITMAPDATA
->m_ok
= (M_BITMAPDATA
->m_hBitmap
!= NULL
) ;
277 return M_BITMAPDATA
->m_ok
;
280 void wxBitmap::SetHBITMAP(WXHBITMAP bmp
)
282 M_BITMAPDATA
->m_bitmapType
= kMacBitmapTypeGrafWorld
;
283 M_BITMAPDATA
->m_hBitmap
= bmp
;
284 M_BITMAPDATA
->m_ok
= (M_BITMAPDATA
->m_hBitmap
!= NULL
) ;
287 bool wxBitmap::LoadFile(const wxString
& filename
, long type
)
291 m_refData
= new wxBitmapRefData
;
293 wxBitmapHandler
*handler
= FindHandler(type
);
295 if ( handler
== NULL
) {
296 wxLogWarning("no bitmap handler for type %d defined.", type
);
301 return handler
->LoadFile(this, filename
, type
, -1, -1);
304 bool wxBitmap::Create(void *data
, long type
, int width
, int height
, int depth
)
308 m_refData
= new wxBitmapRefData
;
310 wxBitmapHandler
*handler
= FindHandler(type
);
312 if ( handler
== NULL
) {
313 wxLogWarning("no bitmap handler for type %d defined.", type
);
318 return handler
->Create(this, data
, type
, width
, height
, depth
);
321 bool wxBitmap::SaveFile(const wxString
& filename
, int type
, const wxPalette
*palette
)
323 wxBitmapHandler
*handler
= FindHandler(type
);
325 if ( handler
== NULL
) {
326 wxLogWarning("no bitmap handler for type %d defined.", type
);
331 return handler
->SaveFile(this, filename
, type
, palette
);
334 void wxBitmap::SetWidth(int w
)
337 m_refData
= new wxBitmapRefData
;
339 M_BITMAPDATA
->m_width
= w
;
342 void wxBitmap::SetHeight(int h
)
345 m_refData
= new wxBitmapRefData
;
347 M_BITMAPDATA
->m_height
= h
;
350 void wxBitmap::SetDepth(int d
)
353 m_refData
= new wxBitmapRefData
;
355 M_BITMAPDATA
->m_depth
= d
;
358 void wxBitmap::SetQuality(int q
)
361 m_refData
= new wxBitmapRefData
;
363 M_BITMAPDATA
->m_quality
= q
;
366 void wxBitmap::SetOk(bool isOk
)
369 m_refData
= new wxBitmapRefData
;
371 M_BITMAPDATA
->m_ok
= isOk
;
374 void wxBitmap::SetPalette(const wxPalette
& palette
)
377 m_refData
= new wxBitmapRefData
;
379 M_BITMAPDATA
->m_bitmapPalette
= palette
;
382 void wxBitmap::SetMask(wxMask
*mask
)
385 m_refData
= new wxBitmapRefData
;
387 M_BITMAPDATA
->m_bitmapMask
= mask
;
390 void wxBitmap::AddHandler(wxBitmapHandler
*handler
)
392 sm_handlers
.Append(handler
);
395 void wxBitmap::InsertHandler(wxBitmapHandler
*handler
)
397 sm_handlers
.Insert(handler
);
400 bool wxBitmap::RemoveHandler(const wxString
& name
)
402 wxBitmapHandler
*handler
= FindHandler(name
);
405 sm_handlers
.DeleteObject(handler
);
412 wxBitmapHandler
*wxBitmap::FindHandler(const wxString
& name
)
414 wxNode
*node
= sm_handlers
.First();
417 wxBitmapHandler
*handler
= (wxBitmapHandler
*)node
->Data();
418 if ( handler
->GetName() == name
)
425 wxBitmapHandler
*wxBitmap::FindHandler(const wxString
& extension
, long bitmapType
)
427 wxNode
*node
= sm_handlers
.First();
430 wxBitmapHandler
*handler
= (wxBitmapHandler
*)node
->Data();
431 if ( handler
->GetExtension() == extension
&&
432 (bitmapType
== -1 || handler
->GetType() == bitmapType
) )
439 wxBitmapHandler
*wxBitmap::FindHandler(long bitmapType
)
441 wxNode
*node
= sm_handlers
.First();
444 wxBitmapHandler
*handler
= (wxBitmapHandler
*)node
->Data();
445 if (handler
->GetType() == bitmapType
)
461 // Construct a mask from a bitmap and a colour indicating
462 // the transparent area
463 wxMask::wxMask(const wxBitmap
& bitmap
, const wxColour
& colour
)
466 Create(bitmap
, colour
);
469 // Construct a mask from a bitmap and a palette index indicating
470 // the transparent area
471 wxMask::wxMask(const wxBitmap
& bitmap
, int paletteIndex
)
474 Create(bitmap
, paletteIndex
);
477 // Construct a mask from a mono bitmap (copies the bitmap).
478 wxMask::wxMask(const wxBitmap
& bitmap
)
488 wxMacDestroyGWorld( m_maskBitmap
) ;
489 m_maskBitmap
= NULL
;
493 // Create a mask from a mono bitmap (copies the bitmap).
494 bool wxMask::Create(const wxBitmap
& bitmap
)
500 // Create a mask from a bitmap and a palette index indicating
501 // the transparent area
502 bool wxMask::Create(const wxBitmap
& bitmap
, int paletteIndex
)
508 // Create a mask from a bitmap and a colour indicating
509 // the transparent area
510 bool wxMask::Create(const wxBitmap
& bitmap
, const wxColour
& colour
)
514 wxMacDestroyGWorld( m_maskBitmap
) ;
515 m_maskBitmap
= NULL
;
517 wxASSERT( ((wxBitmapRefData
*) bitmap
.GetRefData())->m_bitmapType
== kMacBitmapTypeGrafWorld
) ;
518 // other types would require a temporary bitmap. not yet implemented
525 m_maskBitmap
= wxMacCreateGWorld( bitmap
.GetWidth() , bitmap
.GetHeight() , 1 ) ;
526 LockPixels( GetGWorldPixMap( (CGrafPtr
) m_maskBitmap
) ) ;
527 LockPixels( GetGWorldPixMap( (CGrafPtr
) ((wxBitmapRefData
*) bitmap
.GetRefData())->m_hBitmap
) ) ;
528 RGBColor maskColor
= colour
.GetPixel() ;
530 // this is not very efficient, but I can't think
531 // of a better way of doing it
533 GDHandle origDevice
;
535 GetGWorld( &origPort
, &origDevice
) ;
536 for (int w
= 0; w
< bitmap
.GetWidth(); w
++)
538 for (int h
= 0; h
< bitmap
.GetHeight(); h
++)
540 RGBColor colors
[2] = {
541 { 0xFFFF , 0xFFFF , 0xFFFF } ,
545 SetGWorld( ((wxBitmapRefData
*) bitmap
.GetRefData())->m_hBitmap
, NULL
) ;
547 GetCPixel( w
, h
, &col
) ;
548 SetGWorld( m_maskBitmap
, NULL
) ;
549 if (col
.red
== maskColor
.red
&& col
.blue
== maskColor
.blue
&& col
.green
== maskColor
.green
)
551 SetCPixel( w
, h
, &colors
[0] ) ;
555 SetCPixel( w
, h
, &colors
[1] ) ;
559 UnlockPixels( GetGWorldPixMap( (CGrafPtr
) m_maskBitmap
) ) ;
560 UnlockPixels( GetGWorldPixMap( ((wxBitmapRefData
*) bitmap
.GetRefData())->m_hBitmap
) ) ;
561 SetGWorld( origPort
, origDevice
) ;
570 IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler
, wxObject
)
572 bool wxBitmapHandler::Create(wxBitmap
*bitmap
, void *data
, long type
, int width
, int height
, int depth
)
577 bool wxBitmapHandler::LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long type
,
578 int desiredWidth
, int desiredHeight
)
583 bool wxBitmapHandler::SaveFile(wxBitmap
*bitmap
, const wxString
& name
, int type
, const wxPalette
*palette
)
592 class WXDLLEXPORT wxPICTResourceHandler
: public wxBitmapHandler
594 DECLARE_DYNAMIC_CLASS(wxPICTResourceHandler
)
596 inline wxPICTResourceHandler()
598 m_name
= "Macintosh Pict resource";
600 m_type
= wxBITMAP_TYPE_PICT_RESOURCE
;
603 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
604 int desiredWidth
, int desiredHeight
);
606 IMPLEMENT_DYNAMIC_CLASS(wxPICTResourceHandler
, wxBitmapHandler
)
608 bool wxPICTResourceHandler::LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
609 int desiredWidth
, int desiredHeight
)
614 c2pstrcpy( (StringPtr
) theName
, name
) ;
616 strcpy( (char *) theName
, name
) ;
617 c2pstr( (char *)theName
) ;
620 PicHandle thePict
= (PicHandle
) GetNamedResource( 'PICT' , theName
) ;
625 GetPictInfo( thePict
, &theInfo
, 0 , 0 , systemMethod
, 0 ) ;
626 DetachResource( (Handle
) thePict
) ;
627 M_BITMAPHANDLERDATA
->m_bitmapType
= kMacBitmapTypePict
;
628 M_BITMAPHANDLERDATA
->m_hPict
= thePict
;
629 M_BITMAPHANDLERDATA
->m_width
= theInfo
.sourceRect
.right
- theInfo
.sourceRect
.left
;
630 M_BITMAPHANDLERDATA
->m_height
= theInfo
.sourceRect
.bottom
- theInfo
.sourceRect
.top
;
632 M_BITMAPHANDLERDATA
->m_depth
= theInfo
.depth
;
633 M_BITMAPHANDLERDATA
->m_ok
= true ;
634 M_BITMAPHANDLERDATA
->m_numColors
= theInfo
.uniqueColors
;
635 // M_BITMAPHANDLERDATA->m_bitmapPalette;
636 // M_BITMAPHANDLERDATA->m_quality;
642 /* TODO: bitmap handlers, a bit like this:
643 class WXDLLEXPORT wxBMPResourceHandler: public wxBitmapHandler
645 DECLARE_DYNAMIC_CLASS(wxBMPResourceHandler)
647 inline wxBMPResourceHandler()
649 m_name = "Windows bitmap resource";
651 m_type = wxBITMAP_TYPE_BMP_RESOURCE;
654 virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
655 int desiredWidth, int desiredHeight);
657 IMPLEMENT_DYNAMIC_CLASS(wxBMPResourceHandler, wxBitmapHandler)
660 class WXDLLEXPORT wxXPMFileHandler
: public wxBitmapHandler
662 DECLARE_DYNAMIC_CLASS(wxXPMFileHandler
)
664 inline wxXPMFileHandler(void)
666 m_name
= "XPM bitmap file";
668 m_type
= wxBITMAP_TYPE_XPM
;
671 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
672 int desiredWidth
= -1, int desiredHeight
= -1);
673 virtual bool SaveFile(wxBitmap
*bitmap
, const wxString
& name
, int type
, const wxPalette
*palette
= NULL
);
675 IMPLEMENT_DYNAMIC_CLASS(wxXPMFileHandler
, wxBitmapHandler
)
677 bool wxXPMFileHandler::LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
678 int desiredWidth
, int desiredHeight
)
682 XpmAttributes xpmAttr
;
685 M_BITMAPHANDLERDATA
->m_ok
= FALSE
;
686 dc
= CreateCompatibleDC(NULL
);
689 xpmAttr
.valuemask
= XpmReturnPixels
;
690 int errorStatus
= XpmReadFileToImage(&dc
, WXSTRINGCAST name
, &ximage
, (XImage
**) NULL
, &xpmAttr
);
692 if (errorStatus
== XpmSuccess
)
694 M_BITMAPHANDLERDATA
->m_hBitmap
= (WXHBITMAP
) ximage
->bitmap
;
697 GetObject((HBITMAP
)M_BITMAPHANDLERDATA
->m_hBitmap
, sizeof(bm
), (LPSTR
) & bm
);
699 M_BITMAPHANDLERDATA
->m_width
= (bm
.bmWidth
);
700 M_BITMAPHANDLERDATA
->m_height
= (bm
.bmHeight
);
701 M_BITMAPHANDLERDATA
->m_depth
= (bm
.bmPlanes
* bm
.bmBitsPixel
);
702 M_BITMAPHANDLERDATA
->m_numColors
= xpmAttr
.npixels
;
703 XpmFreeAttributes(&xpmAttr
);
706 M_BITMAPHANDLERDATA
->m_ok
= TRUE
;
711 M_BITMAPHANDLERDATA
->m_ok
= FALSE
;
720 bool wxXPMFileHandler::SaveFile(wxBitmap
*bitmap
, const wxString
& name
, int type
, const wxPalette
*palette
)
725 Visual
*visual
= NULL
;
728 dc
= CreateCompatibleDC(NULL
);
731 if (SelectObject(dc
, (HBITMAP
) M_BITMAPHANDLERDATA
->m_hBitmap
))
734 ximage
.width
= M_BITMAPHANDLERDATA
->m_width
;
735 ximage
.height
= M_BITMAPHANDLERDATA
->m_height
;
736 ximage
.depth
= M_BITMAPHANDLERDATA
->m_depth
;
737 ximage
.bitmap
= (void *)M_BITMAPHANDLERDATA
->m_hBitmap
;
738 int errorStatus
= XpmWriteFileFromImage(&dc
, WXSTRINGCAST name
,
739 &ximage
, (XImage
*) NULL
, (XpmAttributes
*) NULL
);
744 if (errorStatus
== XpmSuccess
)
756 class WXDLLEXPORT wxXPMDataHandler
: public wxBitmapHandler
758 DECLARE_DYNAMIC_CLASS(wxXPMDataHandler
)
760 inline wxXPMDataHandler(void)
762 m_name
= "XPM bitmap data";
764 m_type
= wxBITMAP_TYPE_XPM_DATA
;
767 virtual bool Create(wxBitmap
*bitmap
, void *data
, long flags
, int width
, int height
, int depth
= 1);
769 IMPLEMENT_DYNAMIC_CLASS(wxXPMDataHandler
, wxBitmapHandler
)
771 bool wxXPMDataHandler::Create(wxBitmap
*bitmap
, void *data
, long flags
, int width
, int height
, int depth
)
773 XImage
* ximage
= NULL
;
774 XImage
* xshapeimage
= NULL
;
776 XpmAttributes xpmAttr
;
778 xpmAttr
.valuemask
= XpmReturnInfos
; // get infos back
779 ErrorStatus
= XpmCreateImageFromData( GetMainDevice() , (char **)data
,
780 &ximage
, &xshapeimage
, &xpmAttr
);
782 if (ErrorStatus
== XpmSuccess
)
784 M_BITMAPHANDLERDATA
->m_ok
= FALSE
;
785 M_BITMAPHANDLERDATA
->m_numColors
= 0;
786 M_BITMAPHANDLERDATA
->m_hBitmap
= ximage
->gworldptr
;
788 M_BITMAPHANDLERDATA
->m_width
= ximage
->width
;
789 M_BITMAPHANDLERDATA
->m_height
= ximage
->height
;
790 M_BITMAPHANDLERDATA
->m_depth
= ximage
->depth
;
791 M_BITMAPHANDLERDATA
->m_numColors
= xpmAttr
.npixels
;
792 XpmFreeAttributes(&xpmAttr
);
793 M_BITMAPHANDLERDATA
->m_ok
= TRUE
;
794 ximage
->gworldptr
= NULL
;
795 XImageFree(ximage
); // releases the malloc, but does not detroy
797 M_BITMAPHANDLERDATA
->m_bitmapType
= kMacBitmapTypeGrafWorld
;
798 if ( xshapeimage
!= NULL
)
800 wxMask
* m
= new wxMask() ;
801 m
->SetMaskBitmap( xshapeimage
->gworldptr
) ;
802 M_BITMAPHANDLERDATA
->m_bitmapMask
= m
;
808 M_BITMAPHANDLERDATA
->m_ok
= FALSE
;
814 class WXDLLEXPORT wxBMPResourceHandler
: public wxBitmapHandler
816 DECLARE_DYNAMIC_CLASS(wxBMPResourceHandler
)
818 inline wxBMPResourceHandler()
820 m_name
= "Windows bitmap resource";
822 m_type
= wxBITMAP_TYPE_BMP_RESOURCE
;
825 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
826 int desiredWidth
, int desiredHeight
);
829 IMPLEMENT_DYNAMIC_CLASS(wxBMPResourceHandler
, wxBitmapHandler
)
831 bool wxBMPResourceHandler::LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
832 int desiredWidth
, int desiredHeight
)
834 // TODO: load colourmap.
835 // it's probably not found
836 wxLogError("Can't load bitmap '%s' from resources! Check .rc file.", name
.c_str());
841 class WXDLLEXPORT wxBMPFileHandler
: public wxBitmapHandler
843 DECLARE_DYNAMIC_CLASS(wxBMPFileHandler
)
845 inline wxBMPFileHandler(void)
847 m_name
= "Windows bitmap file";
849 m_type
= wxBITMAP_TYPE_BMP
;
852 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
853 int desiredWidth
, int desiredHeight
);
854 virtual bool SaveFile(wxBitmap
*bitmap
, const wxString
& name
, int type
, const wxPalette
*palette
= NULL
);
857 IMPLEMENT_DYNAMIC_CLASS(wxBMPFileHandler
, wxBitmapHandler
)
859 bool wxBMPFileHandler::LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
860 int desiredWidth
, int desiredHeight
)
862 #if USE_IMAGE_LOADING_IN_MSW
863 wxPalette
*palette
= NULL
;
864 bool success
= FALSE
;
865 success
= (wxLoadIntoBitmap(WXSTRINGCAST name
, bitmap
, &palette
) != 0);
866 if (!success
&& palette
)
872 M_BITMAPHANDLERDATA
->m_bitmapPalette
= *palette
;
879 bool wxBMPFileHandler::SaveFile(wxBitmap
*bitmap
, const wxString
& name
, int type
, const wxPalette
*pal
)
881 #if USE_IMAGE_LOADING_IN_MSW
882 wxPalette
*actualPalette
= (wxPalette
*)pal
;
883 if (!actualPalette
&& (!M_BITMAPHANDLERDATA
->m_bitmapPalette
.IsNull()))
884 actualPalette
= & (M_BITMAPHANDLERDATA
->m_bitmapPalette
);
885 return (wxSaveBitmap(WXSTRINGCAST name
, bitmap
, actualPalette
) != 0);
892 void wxBitmap::CleanUpHandlers()
894 wxNode
*node
= sm_handlers
.First();
897 wxBitmapHandler
*handler
= (wxBitmapHandler
*)node
->Data();
898 wxNode
*next
= node
->Next();
905 void wxBitmap::InitStandardHandlers()
907 AddHandler( new wxPICTResourceHandler
) ;
908 AddHandler( new wxICONResourceHandler
) ;
909 AddHandler(new wxXPMFileHandler
);
910 AddHandler(new wxXPMDataHandler
);
911 AddHandler(new wxBMPResourceHandler
);
912 AddHandler(new wxBMPFileHandler
);