]> git.saurik.com Git - wxWidgets.git/blame - include/wx/imagbmp.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / imagbmp.h
CommitLineData
8f493002 1/////////////////////////////////////////////////////////////////////////////
ce7208d4 2// Name: wx/imagbmp.h
72045d57 3// Purpose: wxImage BMP, ICO, CUR and ANI handlers
05813ada 4// Author: Robert Roebling, Chris Elliott
05813ada 5// Copyright: (c) Robert Roebling, Chris Elliott
65571936 6// Licence: wxWindows licence
8f493002
VS
7/////////////////////////////////////////////////////////////////////////////
8
9#ifndef _WX_IMAGBMP_H_
10#define _WX_IMAGBMP_H_
11
8f493002
VS
12#include "wx/image.h"
13
1971d23c 14// defines for saving the BMP file in different formats, Bits Per Pixel
fd94e8aa 15// USE: wximage.SetOption( wxIMAGE_OPTION_BMP_FORMAT, wxBMP_xBPP );
9a83f860 16#define wxIMAGE_OPTION_BMP_FORMAT wxString(wxT("wxBMP_FORMAT"))
fd94e8aa
VS
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
1971d23c
VZ
23
24enum
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
f6bcfd97 38// ----------------------------------------------------------------------------
8f493002 39// wxBMPHandler
f6bcfd97 40// ----------------------------------------------------------------------------
8f493002 41
53a2db12 42class WXDLLIMPEXP_CORE wxBMPHandler : public wxImageHandler
8f493002 43{
8f493002 44public:
52b64b0a
RR
45 wxBMPHandler()
46 {
9a83f860
VZ
47 m_name = wxT("Windows bitmap file");
48 m_extension = wxT("bmp");
52b64b0a 49 m_type = wxBITMAP_TYPE_BMP;
9a83f860 50 m_mime = wxT("image/x-bmp");
47b378bd 51 }
8f493002
VS
52
53#if wxUSE_STREAMS
7beb59f3
WS
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 );
574c939e 56
52b64b0a 57protected:
6f02a879 58 virtual bool DoCanRead( wxInputStream& stream );
574c939e 59 bool SaveDib(wxImage *image, wxOutputStream& stream, bool verbose,
05813ada 60 bool IsBmp, bool IsMask);
574c939e 61 bool DoLoadDib(wxImage *image, int width, int height, int bpp, int ncolors,
1b941f2d 62 int comp, wxFileOffset bmpOffset, wxInputStream& stream,
05813ada
VS
63 bool verbose, bool IsBmp, bool hasPalette);
64 bool LoadDib(wxImage *image, wxInputStream& stream, bool verbose, bool IsBmp);
52b64b0a 65#endif // wxUSE_STREAMS
f6bcfd97 66
52b64b0a
RR
67private:
68 DECLARE_DYNAMIC_CLASS(wxBMPHandler)
69};
70
658974ae 71#if wxUSE_ICO_CUR
52b64b0a
RR
72// ----------------------------------------------------------------------------
73// wxICOHandler
74// ----------------------------------------------------------------------------
75
53a2db12 76class WXDLLIMPEXP_CORE wxICOHandler : public wxBMPHandler
52b64b0a
RR
77{
78public:
79 wxICOHandler()
80 {
9a83f860
VZ
81 m_name = wxT("Windows icon file");
82 m_extension = wxT("ico");
52b64b0a 83 m_type = wxBITMAP_TYPE_ICO;
9a83f860 84 m_mime = wxT("image/x-ico");
47b378bd 85 }
52b64b0a
RR
86
87#if wxUSE_STREAMS
7beb59f3
WS
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 );
658974ae 90 virtual bool DoLoadFile( wxImage *image, wxInputStream& stream, bool verbose, int index );
03647350 91
6f02a879 92protected:
8faef7cc 93 virtual int DoGetImageCount( wxInputStream& stream );
6f02a879 94 virtual bool DoCanRead( wxInputStream& stream );
f6bcfd97
BP
95#endif // wxUSE_STREAMS
96
52b64b0a 97private:
05813ada 98 DECLARE_DYNAMIC_CLASS(wxICOHandler)
8f493002
VS
99};
100
101
05813ada
VS
102// ----------------------------------------------------------------------------
103// wxCURHandler
104// ----------------------------------------------------------------------------
105
53a2db12 106class WXDLLIMPEXP_CORE wxCURHandler : public wxICOHandler
05813ada
VS
107{
108public:
109 wxCURHandler()
110 {
9a83f860
VZ
111 m_name = wxT("Windows cursor file");
112 m_extension = wxT("cur");
05813ada 113 m_type = wxBITMAP_TYPE_CUR;
9a83f860 114 m_mime = wxT("image/x-cur");
47b378bd 115 }
574c939e 116
05813ada
VS
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
6f02a879 121protected:
05813ada
VS
122#if wxUSE_STREAMS
123 virtual bool DoCanRead( wxInputStream& stream );
124#endif // wxUSE_STREAMS
125
126private:
127 DECLARE_DYNAMIC_CLASS(wxCURHandler)
128};
658974ae
VS
129// ----------------------------------------------------------------------------
130// wxANIHandler
131// ----------------------------------------------------------------------------
132
53a2db12 133class WXDLLIMPEXP_CORE wxANIHandler : public wxCURHandler
658974ae
VS
134{
135public:
136 wxANIHandler()
137 {
9a83f860
VZ
138 m_name = wxT("Windows animated cursor file");
139 m_extension = wxT("ani");
658974ae 140 m_type = wxBITMAP_TYPE_ANI;
9a83f860 141 m_mime = wxT("image/x-ani");
47b378bd 142 }
574c939e 143
658974ae
VS
144
145#if wxUSE_STREAMS
47b378bd 146 virtual bool SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSED(stream), bool WXUNUSED(verbose=true) ){return false ;}
7beb59f3 147 virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 );
8faef7cc 148
6f02a879 149protected:
8faef7cc 150 virtual int DoGetImageCount( wxInputStream& stream );
6f02a879 151 virtual bool DoCanRead( wxInputStream& stream );
658974ae
VS
152#endif // wxUSE_STREAMS
153
154private:
155 DECLARE_DYNAMIC_CLASS(wxANIHandler)
156};
8f493002 157
658974ae 158#endif // wxUSE_ICO_CUR
05813ada 159#endif // _WX_IMAGBMP_H_