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 //-----------------------------------------------------------------------------
23 struct GifHashTableType
;
24 class WXDLLIMPEXP_FWD_CORE wxImageArray
; // anidecod.h
26 class WXDLLIMPEXP_CORE wxGIFHandler
: public wxImageHandler
31 m_name
= wxT("GIF file");
32 m_extension
= wxT("gif");
33 m_type
= wxBITMAP_TYPE_GIF
;
34 m_mime
= wxT("image/gif");
39 virtual bool LoadFile(wxImage
*image
, wxInputStream
& stream
,
40 bool verbose
= true, int index
= -1);
41 virtual bool SaveFile(wxImage
*image
, wxOutputStream
& stream
,
45 bool SaveAnimation(const wxImageArray
& images
, wxOutputStream
*stream
,
46 bool verbose
= true, int delayMilliSecs
= 1000,
47 const wxString
& comment
= wxEmptyString
);
50 virtual int DoGetImageCount(wxInputStream
& stream
);
51 virtual bool DoCanRead(wxInputStream
& stream
);
53 bool DoSaveFile(const wxImage
&, wxOutputStream
*, bool verbose
,
54 bool first
, int delayMilliSecs
, bool loop
,
55 const wxRGB
*pal
, int palCount
,
56 int mask_index
, const wxString
& comment
= wxEmptyString
);
57 #endif // wxUSE_STREAMS
60 // Declarations for saving
62 unsigned long m_crntShiftDWord
; /* For bytes decomposition into codes. */
64 struct GifHashTableType
*m_hashTable
;
66 m_EOFCode
, /* The EOF LZ code. */
67 m_clearCode
, /* The CLEAR LZ code. */
68 m_runningCode
, /* The next code algorithm can generate. */
69 m_runningBits
, /* The number of bits required to represent RunningCode. */
70 m_maxCode1
, /* 1 bigger than max. possible code, in RunningBits bits. */
71 m_crntCode
, /* Current algorithm code. */
72 m_crntShiftState
; /* Number of bits in CrntShiftDWord. */
73 wxUint8 m_LZBuf
[256]; /* Compressed input is buffered here. */
76 void ClearHashTable();
77 void InsertHashTable(unsigned long key
, int code
);
78 int ExistsHashTable(unsigned long key
);
81 bool CompressOutput(wxOutputStream
*, int code
);
82 bool SetupCompress(wxOutputStream
*, int bpp
);
83 bool CompressLine(wxOutputStream
*, const wxUint8
*line
, int lineLen
);
86 static wxString ms_comment
;
88 DECLARE_DYNAMIC_CLASS(wxGIFHandler
)
93 #endif // _WX_IMAGGIF_H_