]>
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 // --------------------------------------------------------------------------
33 wxGIF_D_UNSPECIFIED
= -1, /* not specified */
34 wxGIF_D_DONOTDISPOSE
= 0, /* do not dispose */
35 wxGIF_D_TOBACKGROUND
= 1, /* restore to background colour */
36 wxGIF_D_TOPREVIOUS
= 2 /* restore to previous image */
42 wxGIF_OK
= 0, /* everything was OK */
43 wxGIF_INVFORMAT
= 1, /* error in gif header */
44 wxGIF_MEMERR
= 2 /* error allocating memory */
47 #define MAX_BLOCK_SIZE 256 /* max. block size */
50 // --------------------------------------------------------------------------
52 // --------------------------------------------------------------------------
54 // internal class for storing GIF image data
58 unsigned int w
; /* width */
59 unsigned int h
; /* height */
60 unsigned int left
; /* x coord (in logical screen) */
61 unsigned int top
; /* y coord (in logical screen) */
62 int transparent
; /* transparent color (-1 = none) */
63 int disposal
; /* disposal method (-1 = unspecified) */
64 long delay
; /* delay in ms (-1 = unused) */
65 unsigned char *p
; /* bitmap */
66 unsigned char *pal
; /* palette */
67 GIFImage
*next
; /* next image */
68 GIFImage
*prev
; /* prev image */
72 class WXDLLEXPORT wxGIFDecoder
76 unsigned int m_screenw
; /* logical screen width */
77 unsigned int m_screenh
; /* logical screen height */
78 int m_background
; /* background color (-1 = none) */
81 bool m_anim
; /* animated GIF */
82 int m_nimages
; /* number of images */
83 int m_image
; /* current image */
84 GIFImage
*m_pimage
; /* pointer to current image */
85 GIFImage
*m_pfirst
; /* pointer to first image */
86 GIFImage
*m_plast
; /* pointer to last image */
89 int m_restbits
; /* remaining valid bits */
90 unsigned int m_restbyte
; /* remaining bytes in this block */
91 unsigned int m_lastbyte
; /* last byte read */
92 unsigned char m_buffer
[MAX_BLOCK_SIZE
]; /* buffer for reading */
93 unsigned char *m_bufp
; /* pointer to next byte in buffer */
96 wxInputStream
*m_f
; /* input stream */
99 int getcode(int bits
, int abfin
);
100 int dgif(GIFImage
*img
, int interl
, int bits
);
103 // get data of current frame
104 int GetFrameIndex() const;
105 unsigned char* GetData() const;
106 unsigned char* GetPalette() const;
107 unsigned int GetWidth() const;
108 unsigned int GetHeight() const;
109 unsigned int GetLeft() const;
110 unsigned int GetTop() const;
111 int GetDisposalMethod() const;
112 int GetTransparentColour() const;
113 long GetDelay() const;
116 unsigned int GetLogicalScreenWidth() const;
117 unsigned int GetLogicalScreenHeight() const;
118 int GetBackgroundColour() const;
119 int GetNumberOfFrames() const;
120 bool IsAnimation() const;
122 // move through the animation
125 bool GoNextFrame(bool cyclic
= FALSE
);
126 bool GoPrevFrame(bool cyclic
= FALSE
);
127 bool GoFrame(int which
);
130 // constructor, destructor, etc.
131 wxGIFDecoder(wxInputStream
*s
, bool anim
= FALSE
);
137 // convert current frame to wxImage
138 bool ConvertToImage(wxImage
*image
) const;
142 #endif // wxUSE_STREAM && wxUSE_GIF
143 #endif // _WX_GIFDECOD_H