]> git.saurik.com Git - wxWidgets.git/blob - include/wx/iffdecod.h
wxFont::IsFixedWidth for wxMGL
[wxWidgets.git] / include / wx / iffdecod.h
1 //
2 // iffdecod.h - image handler for IFF/ILBM images
3 //
4 // (c) Steffen Gutmann, 2002
5 //
6 // Creation date: 08.01.2002
7 // Last modified: 12.01.2002
8 //
9
10 #ifndef WX_IIF_DECODE_H
11 #define WX_IIF_DECODE_H
12
13 #ifdef __GNUG__
14 #pragma interface "iffdecod.h"
15 #endif
16
17 #include "wx/setup.h"
18 #define wxUSE_IFF 1
19
20 #if wxUSE_STREAMS && wxUSE_IFF
21
22 #include "wx/stream.h"
23 #include "wx/image.h"
24
25 // --------------------------------------------------------------------------
26 // Constants
27 // --------------------------------------------------------------------------
28
29 // Error codes:
30 // Note that the error code wxIFF_TRUNCATED means that the image itself
31 // is most probably OK, but the decoder didn't reach the end of the data
32 // stream; this means that if it was not reading directly from file,
33 // the stream will not be correctly positioned.
34 //
35
36 enum
37 {
38 wxIFF_OK = 0, /* everything was OK */
39 wxIFF_INVFORMAT, /* error in iff header */
40 wxIFF_MEMERR, /* error allocating memory */
41 wxIFF_TRUNCATED /* file appears to be truncated */
42 };
43
44 // --------------------------------------------------------------------------
45 // wxIFFDecoder class
46 // --------------------------------------------------------------------------
47
48 // internal class for storing IFF image data
49 class IFFImage
50 {
51 public:
52 unsigned int w; /* width */
53 unsigned int h; /* height */
54 int transparent; /* transparent color (-1 = none) */
55 int colors; /* number of colors */
56 unsigned char *p; /* bitmap */
57 unsigned char *pal; /* palette */
58
59 IFFImage() : w(0), h(0), colors(0), p(0), pal(0) {}
60 ~IFFImage() { delete [] p; delete [] pal; }
61 };
62
63 class WXDLLEXPORT wxIFFDecoder
64 {
65 private:
66 IFFImage *m_image; // image data
67 wxInputStream *m_f; // input stream
68 unsigned char *databuf;
69 unsigned char *picptr;
70 unsigned char *decomp_mem;
71
72 void Destroy();
73
74 public:
75 // get data of current frame
76 unsigned char* GetData() const;
77 unsigned char* GetPalette() const;
78 int GetNumColors() const;
79 unsigned int GetWidth() const;
80 unsigned int GetHeight() const;
81 int GetTransparentColour() const;
82
83 // constructor, destructor, etc.
84 wxIFFDecoder(wxInputStream *s);
85 ~wxIFFDecoder() { Destroy(); }
86 bool CanRead();
87 int ReadIFF();
88 bool ConvertToImage(wxImage *image) const;
89 };
90
91
92 #endif // wxUSE_STREAM && wxUSE_IFF
93 #endif // _WX_IFFDECOD_H
94