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