Use RIAA wrapper for wxSpinCtrl event disabling in wxGTK.
[wxWidgets.git] / include / wx / imagbmp.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/imagbmp.h
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 /////////////////////////////////////////////////////////////////////////////
8
9 #ifndef _WX_IMAGBMP_H_
10 #define _WX_IMAGBMP_H_
11
12 #include "wx/image.h"
13
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"))
17
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")
22
23
24 enum
25 {
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
36 };
37
38 // ----------------------------------------------------------------------------
39 // wxBMPHandler
40 // ----------------------------------------------------------------------------
41
42 class WXDLLIMPEXP_CORE wxBMPHandler : public wxImageHandler
43 {
44 public:
45 wxBMPHandler()
46 {
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");
51 }
52
53 #if wxUSE_STREAMS
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 );
56
57 protected:
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
66
67 private:
68 DECLARE_DYNAMIC_CLASS(wxBMPHandler)
69 };
70
71 #if wxUSE_ICO_CUR
72 // ----------------------------------------------------------------------------
73 // wxICOHandler
74 // ----------------------------------------------------------------------------
75
76 class WXDLLIMPEXP_CORE wxICOHandler : public wxBMPHandler
77 {
78 public:
79 wxICOHandler()
80 {
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");
85 }
86
87 #if wxUSE_STREAMS
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 );
91
92 protected:
93 virtual int DoGetImageCount( wxInputStream& stream );
94 virtual bool DoCanRead( wxInputStream& stream );
95 #endif // wxUSE_STREAMS
96
97 private:
98 DECLARE_DYNAMIC_CLASS(wxICOHandler)
99 };
100
101
102 // ----------------------------------------------------------------------------
103 // wxCURHandler
104 // ----------------------------------------------------------------------------
105
106 class WXDLLIMPEXP_CORE wxCURHandler : public wxICOHandler
107 {
108 public:
109 wxCURHandler()
110 {
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");
115 }
116
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.
120
121 protected:
122 #if wxUSE_STREAMS
123 virtual bool DoCanRead( wxInputStream& stream );
124 #endif // wxUSE_STREAMS
125
126 private:
127 DECLARE_DYNAMIC_CLASS(wxCURHandler)
128 };
129 // ----------------------------------------------------------------------------
130 // wxANIHandler
131 // ----------------------------------------------------------------------------
132
133 class WXDLLIMPEXP_CORE wxANIHandler : public wxCURHandler
134 {
135 public:
136 wxANIHandler()
137 {
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");
142 }
143
144
145 #if wxUSE_STREAMS
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 );
148
149 protected:
150 virtual int DoGetImageCount( wxInputStream& stream );
151 virtual bool DoCanRead( wxInputStream& stream );
152 #endif // wxUSE_STREAMS
153
154 private:
155 DECLARE_DYNAMIC_CLASS(wxANIHandler)
156 };
157
158 #endif // wxUSE_ICO_CUR
159 #endif // _WX_IMAGBMP_H_