]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gifdecod.h
Added tree control item click events
[wxWidgets.git] / include / wx / gifdecod.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: gifdecod.h
3 // Purpose: wxGIFDecoder, GIF reader for wxImage and wxAnimation
4 // Author: Guillermo Rodriguez Garcia <guille@iies.es>
5 // Version: 3.02
6 // CVS-ID: $Id$
7 // Copyright: (c) 1999 Guillermo Rodriguez Garcia
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_GIFDECOD_H
12 #define _WX_GIFDECOD_H
13
14 #ifdef __GNUG__
15 #pragma interface "gifdecod.h"
16 #endif
17
18 #include "wx/setup.h"
19
20 #if wxUSE_STREAMS && wxUSE_GIF
21
22 #include "wx/stream.h"
23 #include "wx/image.h"
24
25
26 typedef struct _IMAGEN
27 {
28 unsigned int w; /* width */
29 unsigned int h; /* height */
30 unsigned int left; /* x coord (in logical screen) */
31 unsigned int top; /* y coord (in logical screen) */
32 int transparent; /* transparent color (-1 = none) */
33 int disposal; /* disposal method (-1 = unspecified) */
34 long delay; /* delay in ms (-1 = unused) */
35 unsigned char *p; /* bitmap */
36 unsigned char *pal; /* palette */
37 struct _IMAGEN *next; /* next image */
38 struct _IMAGEN *prev; /* prev image */
39 } IMAGEN;
40
41
42 /* disposal method */
43 #define D_UNSPECIFIED -1 /* not specified */
44 #define D_DONOTDISPOSE 0 /* do not dispose */
45 #define D_TOBACKGROUND 1 /* restore to background colour */
46 #define D_TOPREVIOUS 2 /* restore to previous image */
47
48 /* error codes */
49 #define E_OK 0 /* everything was OK */
50 #define E_FORMATO 1 /* error in gif header */
51 #define E_MEMORIA 2 /* error allocating memory */
52
53 class WXDLLEXPORT wxGIFDecoder
54 {
55 private:
56 /* logical screen */
57 unsigned int m_screenw; /* logical screen width */
58 unsigned int m_screenh; /* logical screen height */
59 int m_background; /* background color (-1 = none) */
60
61 /* image data */
62 bool m_anim; /* animated GIF */
63 int m_nimages; /* number of images */
64 int m_image; /* current image */
65 IMAGEN *m_pimage; /* pointer to current image */
66 IMAGEN *m_pfirst; /* pointer to first image */
67 IMAGEN *m_plast; /* pointer to last image */
68
69 /* decoder state vars */
70 int m_restbits; /* remaining valid bits */
71 unsigned int m_restbyte; /* remaining bytes in this block */
72 unsigned int m_lastbyte; /* last byte read */
73
74 wxInputStream *m_f; /* input file */
75
76 private:
77 int getcode(int bits, int abfin);
78 int dgif(IMAGEN *img, int interl, int bits);
79
80 public:
81 // constructor, destructor, etc.
82 wxGIFDecoder(wxInputStream *s, bool anim = FALSE);
83 ~wxGIFDecoder();
84 bool CanRead();
85 int ReadGIF();
86 void Destroy();
87
88 // convert current frame to wxImage
89 bool ConvertToImage(wxImage *image) const;
90
91 // get data of current frame
92 int GetFrameIndex() const;
93 unsigned char* GetData() const;
94 unsigned char* GetPalette() const;
95 unsigned int GetWidth() const;
96 unsigned int GetHeight() const;
97 unsigned int GetLeft() const;
98 unsigned int GetTop() const;
99 int GetDisposalMethod() const;
100 int GetTransparentColour() const;
101 long GetDelay() const;
102
103 // get global data
104 unsigned int GetLogicalScreenWidth() const;
105 unsigned int GetLogicalScreenHeight() const;
106 int GetBackgroundColour() const;
107 int GetNumberOfFrames() const;
108 bool IsAnimation() const;
109
110 // move through the animation
111 bool GoFirstFrame();
112 bool GoLastFrame();
113 bool GoNextFrame(bool cyclic = FALSE);
114 bool GoPrevFrame(bool cyclic = FALSE);
115 bool GoFrame(int which);
116 };
117
118
119 #endif // wxUSE_STREAM && wxUSE_GIF
120 #endif // _WX_GIFDECOD_H
121