1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxImage BMP, ICO, CUR and ANI handlers
4 // Author: Robert Roebling, Chris Elliott
5 // Copyright: (c) Robert Roebling, Chris Elliott
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 #define _WX_IMAGBMP_H_
14 // defines for saving the BMP file in different formats, Bits Per Pixel
15 // USE: wximage.SetOption( wxIMAGE_OPTION_BMP_FORMAT, wxBMP_xBPP );
16 #define wxIMAGE_OPTION_BMP_FORMAT wxString(wxT("wxBMP_FORMAT"))
18 // These two options are filled in upon reading CUR file and can (should) be
19 // specified when saving a CUR file - they define the hotspot of the cursor:
20 #define wxIMAGE_OPTION_CUR_HOTSPOT_X wxT("HotSpotX")
21 #define wxIMAGE_OPTION_CUR_HOTSPOT_Y wxT("HotSpotY")
26 wxBMP_24BPP
= 24, // default, do not need to set
27 //wxBMP_16BPP = 16, // wxQuantize can only do 236 colors?
28 wxBMP_8BPP
= 8, // 8bpp, quantized colors
29 wxBMP_8BPP_GREY
= 9, // 8bpp, rgb averaged to greys
30 wxBMP_8BPP_GRAY
= wxBMP_8BPP_GREY
,
31 wxBMP_8BPP_RED
= 10, // 8bpp, red used as greyscale
32 wxBMP_8BPP_PALETTE
= 11, // 8bpp, use the wxImage's palette
33 wxBMP_4BPP
= 4, // 4bpp, quantized colors
34 wxBMP_1BPP
= 1, // 1bpp, quantized "colors"
35 wxBMP_1BPP_BW
= 2 // 1bpp, black & white from red
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 class WXDLLIMPEXP_CORE wxBMPHandler
: public wxImageHandler
47 m_name
= wxT("Windows bitmap file");
48 m_extension
= wxT("bmp");
49 m_type
= wxBITMAP_TYPE_BMP
;
50 m_mime
= wxT("image/x-bmp");
54 virtual bool SaveFile( wxImage
*image
, wxOutputStream
& stream
, bool verbose
=true );
55 virtual bool LoadFile( wxImage
*image
, wxInputStream
& stream
, bool verbose
=true, int index
=-1 );
58 virtual bool DoCanRead( wxInputStream
& stream
);
59 bool SaveDib(wxImage
*image
, wxOutputStream
& stream
, bool verbose
,
60 bool IsBmp
, bool IsMask
);
61 bool DoLoadDib(wxImage
*image
, int width
, int height
, int bpp
, int ncolors
,
62 int comp
, wxFileOffset bmpOffset
, wxInputStream
& stream
,
63 bool verbose
, bool IsBmp
, bool hasPalette
);
64 bool LoadDib(wxImage
*image
, wxInputStream
& stream
, bool verbose
, bool IsBmp
);
65 #endif // wxUSE_STREAMS
68 DECLARE_DYNAMIC_CLASS(wxBMPHandler
)
72 // ----------------------------------------------------------------------------
74 // ----------------------------------------------------------------------------
76 class WXDLLIMPEXP_CORE wxICOHandler
: public wxBMPHandler
81 m_name
= wxT("Windows icon file");
82 m_extension
= wxT("ico");
83 m_type
= wxBITMAP_TYPE_ICO
;
84 m_mime
= wxT("image/x-ico");
88 virtual bool SaveFile( wxImage
*image
, wxOutputStream
& stream
, bool verbose
=true );
89 virtual bool LoadFile( wxImage
*image
, wxInputStream
& stream
, bool verbose
=true, int index
=-1 );
90 virtual bool DoLoadFile( wxImage
*image
, wxInputStream
& stream
, bool verbose
, int index
);
93 virtual int DoGetImageCount( wxInputStream
& stream
);
94 virtual bool DoCanRead( wxInputStream
& stream
);
95 #endif // wxUSE_STREAMS
98 DECLARE_DYNAMIC_CLASS(wxICOHandler
)
102 // ----------------------------------------------------------------------------
104 // ----------------------------------------------------------------------------
106 class WXDLLIMPEXP_CORE wxCURHandler
: public wxICOHandler
111 m_name
= wxT("Windows cursor file");
112 m_extension
= wxT("cur");
113 m_type
= wxBITMAP_TYPE_CUR
;
114 m_mime
= wxT("image/x-cur");
117 // VS: This handler's meat is implemented inside wxICOHandler (the two
118 // formats are almost identical), but we hide this fact at
119 // the API level, since it is a mere implementation detail.
123 virtual bool DoCanRead( wxInputStream
& stream
);
124 #endif // wxUSE_STREAMS
127 DECLARE_DYNAMIC_CLASS(wxCURHandler
)
129 // ----------------------------------------------------------------------------
131 // ----------------------------------------------------------------------------
133 class WXDLLIMPEXP_CORE wxANIHandler
: public wxCURHandler
138 m_name
= wxT("Windows animated cursor file");
139 m_extension
= wxT("ani");
140 m_type
= wxBITMAP_TYPE_ANI
;
141 m_mime
= wxT("image/x-ani");
146 virtual bool SaveFile( wxImage
*WXUNUSED(image
), wxOutputStream
& WXUNUSED(stream
), bool WXUNUSED(verbose
=true) ){return false ;}
147 virtual bool LoadFile( wxImage
*image
, wxInputStream
& stream
, bool verbose
=true, int index
=-1 );
150 virtual int DoGetImageCount( wxInputStream
& stream
);
151 virtual bool DoCanRead( wxInputStream
& stream
);
152 #endif // wxUSE_STREAMS
155 DECLARE_DYNAMIC_CLASS(wxANIHandler
)
158 #endif // wxUSE_ICO_CUR
159 #endif // _WX_IMAGBMP_H_