1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxImage GIF handler
4 // Author: Vaclav Slavik, Guillermo Rodriguez Garcia, Gershon Elber, Troels K
6 // Copyright: (c) 1999-2011 Vaclav Slavik, Guillermo Rodriguez Garcia, Gershon Elber, Troels K
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_IMAGGIF_H_
11 #define _WX_IMAGGIF_H_
16 //-----------------------------------------------------------------------------
18 //-----------------------------------------------------------------------------
22 #define wxIMAGE_OPTION_GIF_COMMENT wxT("GifComment")
25 struct GifHashTableType
;
26 class WXDLLIMPEXP_FWD_CORE wxImageArray
; // anidecod.h
28 class WXDLLIMPEXP_CORE wxGIFHandler
: public wxImageHandler
33 m_name
= wxT("GIF file");
34 m_extension
= wxT("gif");
35 m_type
= wxBITMAP_TYPE_GIF
;
36 m_mime
= wxT("image/gif");
41 virtual bool LoadFile(wxImage
*image
, wxInputStream
& stream
,
42 bool verbose
= true, int index
= -1);
43 virtual bool SaveFile(wxImage
*image
, wxOutputStream
& stream
,
47 bool SaveAnimation(const wxImageArray
& images
, wxOutputStream
*stream
,
48 bool verbose
= true, int delayMilliSecs
= 1000);
51 virtual int DoGetImageCount(wxInputStream
& stream
);
52 virtual bool DoCanRead(wxInputStream
& stream
);
54 bool DoSaveFile(const wxImage
&, wxOutputStream
*, bool verbose
,
55 bool first
, int delayMilliSecs
, bool loop
,
56 const wxRGB
*pal
, int palCount
,
58 #endif // wxUSE_STREAMS
61 // Declarations for saving
63 unsigned long m_crntShiftDWord
; /* For bytes decomposition into codes. */
65 struct GifHashTableType
*m_hashTable
;
67 m_EOFCode
, /* The EOF LZ code. */
68 m_clearCode
, /* The CLEAR LZ code. */
69 m_runningCode
, /* The next code algorithm can generate. */
70 m_runningBits
, /* The number of bits required to represent RunningCode. */
71 m_maxCode1
, /* 1 bigger than max. possible code, in RunningBits bits. */
72 m_crntCode
, /* Current algorithm code. */
73 m_crntShiftState
; /* Number of bits in CrntShiftDWord. */
74 wxUint8 m_LZBuf
[256]; /* Compressed input is buffered here. */
77 void ClearHashTable();
78 void InsertHashTable(unsigned long key
, int code
);
79 int ExistsHashTable(unsigned long key
);
82 bool CompressOutput(wxOutputStream
*, int code
);
83 bool SetupCompress(wxOutputStream
*, int bpp
);
84 bool CompressLine(wxOutputStream
*, const wxUint8
*line
, int lineLen
);
88 DECLARE_DYNAMIC_CLASS(wxGIFHandler
)
93 #endif // _WX_IMAGGIF_H_