]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gifdecod.h
Use correct reload flags on all platforms to avoid compilation errors
[wxWidgets.git] / include / wx / gifdecod.h
CommitLineData
661dc384 1/////////////////////////////////////////////////////////////////////////////
ce7208d4 2// Name: wx/gifdecod.h
661dc384
JS
3// Purpose: wxGIFDecoder, GIF reader for wxImage and wxAnimation
4// Author: Guillermo Rodriguez Garcia <guille@iies.es>
3c87527e 5// Version: 3.02
83413d6d
GRG
6// CVS-ID: $Id$
7// Copyright: (c) 1999 Guillermo Rodriguez Garcia
65571936 8// Licence: wxWindows licence
661dc384
JS
9/////////////////////////////////////////////////////////////////////////////
10
870cf35c
VZ
11#ifndef _WX_GIFDECOD_H_
12#define _WX_GIFDECOD_H_
661dc384 13
2ecf902b 14#include "wx/defs.h"
661dc384 15
83413d6d
GRG
16#if wxUSE_STREAMS && wxUSE_GIF
17
661dc384
JS
18#include "wx/stream.h"
19#include "wx/image.h"
72045d57 20#include "wx/animdecod.h"
7e0bac9d 21#include "wx/dynarray.h"
72045d57
VZ
22
23// internal utility used to store a frame in 8bit-per-pixel format
870cf35c 24class GIFImage;
661dc384
JS
25
26
e4b8154a 27// --------------------------------------------------------------------------
8141573c 28// Constants
e4b8154a
GRG
29// --------------------------------------------------------------------------
30
8141573c
GRG
31// Error codes:
32// Note that the error code wxGIF_TRUNCATED means that the image itself
33// is most probably OK, but the decoder didn't reach the end of the data
34// stream; this means that if it was not reading directly from file,
870cf35c 35// the stream will not be correctly positioned.
8141573c 36//
72045d57 37enum wxGIFErrorCode
8141573c 38{
870cf35c
VZ
39 wxGIF_OK = 0, // everything was OK
40 wxGIF_INVFORMAT, // error in GIF header
41 wxGIF_MEMERR, // error allocating memory
42 wxGIF_TRUNCATED // file appears to be truncated
8141573c
GRG
43};
44
e4b8154a
GRG
45// --------------------------------------------------------------------------
46// wxGIFDecoder class
47// --------------------------------------------------------------------------
48
53a2db12 49class WXDLLIMPEXP_CORE wxGIFDecoder : public wxAnimationDecoder
661dc384 50{
809e8e44 51public:
870cf35c
VZ
52 // constructor, destructor, etc.
53 wxGIFDecoder();
54 ~wxGIFDecoder();
55
661dc384 56 // get data of current frame
870cf35c
VZ
57 unsigned char* GetData(unsigned int frame) const;
58 unsigned char* GetPalette(unsigned int frame) const;
59 unsigned int GetNcolours(unsigned int frame) const;
60 int GetTransparentColourIndex(unsigned int frame) const;
61 wxColour GetTransparentColour(unsigned int frame) const;
72045d57 62
870cf35c
VZ
63 virtual wxSize GetFrameSize(unsigned int frame) const;
64 virtual wxPoint GetFramePosition(unsigned int frame) const;
65 virtual wxAnimationDisposal GetDisposalMethod(unsigned int frame) const;
66 virtual long GetDelay(unsigned int frame) const;
72045d57
VZ
67
68 // GIFs can contain both static images and animations
69 bool IsAnimation() const
70 { return m_nFrames > 1; }
e4b8154a 71
72045d57
VZ
72 // load function which returns more info than just Load():
73 wxGIFErrorCode LoadGIF( wxInputStream& stream );
74
75 // free all internal frames
e4b8154a
GRG
76 void Destroy();
77
870cf35c 78 // implementation of wxAnimationDecoder's pure virtuals
72045d57
VZ
79 virtual bool Load( wxInputStream& stream )
80 { return LoadGIF(stream) == wxGIF_OK; }
81
870cf35c 82 bool ConvertToImage(unsigned int frame, wxImage *image) const;
22f3361e 83
72045d57
VZ
84 wxAnimationDecoder *Clone() const
85 { return new wxGIFDecoder; }
86 wxAnimationType GetType() const
87 { return wxANIMATION_TYPE_GIF; }
88
89private:
8faef7cc
FM
90 // wxAnimationDecoder pure virtual
91 virtual bool DoCanRead( wxInputStream& stream ) const;
92 // modifies current stream position (see wxAnimationDecoder::CanRead)
93
94 int getcode(wxInputStream& stream, int bits, int abfin);
95 wxGIFErrorCode dgif(wxInputStream& stream,
96 GIFImage *img, int interl, int bits);
97
03647350 98
870cf35c
VZ
99 // array of all frames
100 wxArrayPtrVoid m_frames;
101
102 // decoder state vars
103 int m_restbits; // remaining valid bits
104 unsigned int m_restbyte; // remaining bytes in this block
105 unsigned int m_lastbyte; // last byte read
106 unsigned char m_buffer[256]; // buffer for reading
107 unsigned char *m_bufp; // pointer to next byte in buffer
108
c0c133e1 109 wxDECLARE_NO_COPY_CLASS(wxGIFDecoder);
661dc384
JS
110};
111
b0f76951 112#endif // wxUSE_STREAMS && wxUSE_GIF
661dc384 113
870cf35c 114#endif // _WX_GIFDECOD_H_