1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxImage BMP, ICO, CUR and ANI handlers
4 // Author: Robert Roebling, Chris Elliott
6 // Copyright: (c) Robert Roebling, Chris Elliott
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_IMAGBMP_H_
11 #define _WX_IMAGBMP_H_
15 // defines for saving the BMP file in different formats, Bits Per Pixel
16 // USE: wximage.SetOption( wxIMAGE_OPTION_BMP_FORMAT, wxBMP_xBPP );
17 #define wxIMAGE_OPTION_BMP_FORMAT wxString(wxT("wxBMP_FORMAT"))
19 // These two options are filled in upon reading CUR file and can (should) be
20 // specified when saving a CUR file - they define the hotspot of the cursor:
21 #define wxIMAGE_OPTION_CUR_HOTSPOT_X wxT("HotSpotX")
22 #define wxIMAGE_OPTION_CUR_HOTSPOT_Y wxT("HotSpotY")
27 wxBMP_24BPP
= 24, // default, do not need to set
28 //wxBMP_16BPP = 16, // wxQuantize can only do 236 colors?
29 wxBMP_8BPP
= 8, // 8bpp, quantized colors
30 wxBMP_8BPP_GREY
= 9, // 8bpp, rgb averaged to greys
31 wxBMP_8BPP_GRAY
= wxBMP_8BPP_GREY
,
32 wxBMP_8BPP_RED
= 10, // 8bpp, red used as greyscale
33 wxBMP_8BPP_PALETTE
= 11, // 8bpp, use the wxImage's palette
34 wxBMP_4BPP
= 4, // 4bpp, quantized colors
35 wxBMP_1BPP
= 1, // 1bpp, quantized "colors"
36 wxBMP_1BPP_BW
= 2 // 1bpp, black & white from red
39 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
43 class WXDLLIMPEXP_CORE wxBMPHandler
: public wxImageHandler
48 m_name
= wxT("Windows bitmap file");
49 m_extension
= wxT("bmp");
50 m_type
= wxBITMAP_TYPE_BMP
;
51 m_mime
= wxT("image/x-bmp");
55 virtual bool SaveFile( wxImage
*image
, wxOutputStream
& stream
, bool verbose
=true );
56 virtual bool LoadFile( wxImage
*image
, wxInputStream
& stream
, bool verbose
=true, int index
=-1 );
59 virtual bool DoCanRead( wxInputStream
& stream
);
60 bool SaveDib(wxImage
*image
, wxOutputStream
& stream
, bool verbose
,
61 bool IsBmp
, bool IsMask
);
62 bool DoLoadDib(wxImage
*image
, int width
, int height
, int bpp
, int ncolors
,
63 int comp
, wxFileOffset bmpOffset
, wxInputStream
& stream
,
64 bool verbose
, bool IsBmp
, bool hasPalette
);
65 bool LoadDib(wxImage
*image
, wxInputStream
& stream
, bool verbose
, bool IsBmp
);
66 #endif // wxUSE_STREAMS
69 DECLARE_DYNAMIC_CLASS(wxBMPHandler
)
73 // ----------------------------------------------------------------------------
75 // ----------------------------------------------------------------------------
77 class WXDLLIMPEXP_CORE wxICOHandler
: public wxBMPHandler
82 m_name
= wxT("Windows icon file");
83 m_extension
= wxT("ico");
84 m_type
= wxBITMAP_TYPE_ICO
;
85 m_mime
= wxT("image/x-ico");
89 virtual bool SaveFile( wxImage
*image
, wxOutputStream
& stream
, bool verbose
=true );
90 virtual bool LoadFile( wxImage
*image
, wxInputStream
& stream
, bool verbose
=true, int index
=-1 );
91 virtual bool DoLoadFile( wxImage
*image
, wxInputStream
& stream
, bool verbose
, int index
);
94 virtual int DoGetImageCount( wxInputStream
& stream
);
95 virtual bool DoCanRead( wxInputStream
& stream
);
96 #endif // wxUSE_STREAMS
99 DECLARE_DYNAMIC_CLASS(wxICOHandler
)
103 // ----------------------------------------------------------------------------
105 // ----------------------------------------------------------------------------
107 class WXDLLIMPEXP_CORE wxCURHandler
: public wxICOHandler
112 m_name
= wxT("Windows cursor file");
113 m_extension
= wxT("cur");
114 m_type
= wxBITMAP_TYPE_CUR
;
115 m_mime
= wxT("image/x-cur");
118 // VS: This handler's meat is implemented inside wxICOHandler (the two
119 // formats are almost identical), but we hide this fact at
120 // the API level, since it is a mere implementation detail.
124 virtual bool DoCanRead( wxInputStream
& stream
);
125 #endif // wxUSE_STREAMS
128 DECLARE_DYNAMIC_CLASS(wxCURHandler
)
130 // ----------------------------------------------------------------------------
132 // ----------------------------------------------------------------------------
134 class WXDLLIMPEXP_CORE wxANIHandler
: public wxCURHandler
139 m_name
= wxT("Windows animated cursor file");
140 m_extension
= wxT("ani");
141 m_type
= wxBITMAP_TYPE_ANI
;
142 m_mime
= wxT("image/x-ani");
147 virtual bool SaveFile( wxImage
*WXUNUSED(image
), wxOutputStream
& WXUNUSED(stream
), bool WXUNUSED(verbose
=true) ){return false ;}
148 virtual bool LoadFile( wxImage
*image
, wxInputStream
& stream
, bool verbose
=true, int index
=-1 );
151 virtual int DoGetImageCount( wxInputStream
& stream
);
152 virtual bool DoCanRead( wxInputStream
& stream
);
153 #endif // wxUSE_STREAMS
156 DECLARE_DYNAMIC_CLASS(wxANIHandler
)
159 #endif // wxUSE_ICO_CUR
160 #endif // _WX_IMAGBMP_H_