]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gifdecod.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxGIFDecoder, GIF reader for wxImage and wxAnimation
4 // Author: Guillermo Rodriguez Garcia <guille@iies.es>
7 // Copyright: (c) 1999 Guillermo Rodriguez Garcia
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_GIFDECOD_H
12 #define _WX_GIFDECOD_H
15 #pragma interface "gifdecod.h"
20 #if wxUSE_STREAMS && wxUSE_GIF
22 #include "wx/stream.h"
26 // --------------------------------------------------------------------------
28 // --------------------------------------------------------------------------
31 // Note that the error code wxGIF_TRUNCATED means that the image itself
32 // is most probably OK, but the decoder didn't reach the end of the data
33 // stream; this means that if it was not reading directly from file,
34 // the stream will not be correctly positioned. the
38 wxGIF_OK
= 0, /* everything was OK */
39 wxGIF_INVFORMAT
, /* error in gif header */
40 wxGIF_MEMERR
, /* error allocating memory */
41 wxGIF_TRUNCATED
/* file appears to be truncated */
45 // Experimental; subject to change.
49 wxGIF_D_UNSPECIFIED
= -1, /* not specified */
50 wxGIF_D_DONOTDISPOSE
= 0, /* do not dispose */
51 wxGIF_D_TOBACKGROUND
= 1, /* restore to background colour */
52 wxGIF_D_TOPREVIOUS
= 2 /* restore to previous image */
56 #define MAX_BLOCK_SIZE 256 /* max. block size */
59 // --------------------------------------------------------------------------
61 // --------------------------------------------------------------------------
63 // internal class for storing GIF image data
67 unsigned int w
; /* width */
68 unsigned int h
; /* height */
69 unsigned int left
; /* x coord (in logical screen) */
70 unsigned int top
; /* y coord (in logical screen) */
71 int transparent
; /* transparent color (-1 = none) */
72 int disposal
; /* disposal method (-1 = unspecified) */
73 long delay
; /* delay in ms (-1 = unused) */
74 unsigned char *p
; /* bitmap */
75 unsigned char *pal
; /* palette */
76 GIFImage
*next
; /* next image */
77 GIFImage
*prev
; /* prev image */
81 class WXDLLEXPORT wxGIFDecoder
85 unsigned int m_screenw
; /* logical screen width */
86 unsigned int m_screenh
; /* logical screen height */
87 int m_background
; /* background color (-1 = none) */
90 bool m_anim
; /* animated GIF */
91 int m_nimages
; /* number of images */
92 int m_image
; /* current image */
93 GIFImage
*m_pimage
; /* pointer to current image */
94 GIFImage
*m_pfirst
; /* pointer to first image */
95 GIFImage
*m_plast
; /* pointer to last image */
98 int m_restbits
; /* remaining valid bits */
99 unsigned int m_restbyte
; /* remaining bytes in this block */
100 unsigned int m_lastbyte
; /* last byte read */
101 unsigned char m_buffer
[MAX_BLOCK_SIZE
]; /* buffer for reading */
102 unsigned char *m_bufp
; /* pointer to next byte in buffer */
105 wxInputStream
*m_f
; /* input stream */
108 int getcode(int bits
, int abfin
);
109 int dgif(GIFImage
*img
, int interl
, int bits
);
112 // get data of current frame
113 int GetFrameIndex() const;
114 unsigned char* GetData() const;
115 unsigned char* GetPalette() const;
116 unsigned int GetWidth() const;
117 unsigned int GetHeight() const;
118 unsigned int GetLeft() const;
119 unsigned int GetTop() const;
120 int GetDisposalMethod() const;
121 int GetTransparentColour() const;
122 long GetDelay() const;
125 unsigned int GetLogicalScreenWidth() const;
126 unsigned int GetLogicalScreenHeight() const;
127 int GetBackgroundColour() const;
128 int GetNumberOfFrames() const;
129 bool IsAnimation() const;
131 // move through the animation
134 bool GoNextFrame(bool cyclic
= FALSE
);
135 bool GoPrevFrame(bool cyclic
= FALSE
);
136 bool GoFrame(int which
);
139 // constructor, destructor, etc.
140 wxGIFDecoder(wxInputStream
*s
, bool anim
= FALSE
);
146 // convert current frame to wxImage
147 bool ConvertToImage(wxImage
*image
) const;
151 #endif // wxUSE_STREAM && wxUSE_GIF
152 #endif // _WX_GIFDECOD_H