1999-12-15 17:38:02 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2009-04-05 08:52:22 -04:00
|
|
|
// Name: wx/imaggif.h
|
1999-12-15 17:38:02 -05:00
|
|
|
// Purpose: wxImage GIF handler
|
2011-01-19 07:28:31 -05:00
|
|
|
// Author: Vaclav Slavik, Guillermo Rodriguez Garcia, Gershon Elber, Troels K
|
1999-12-15 17:38:02 -05:00
|
|
|
// RCS-ID: $Id$
|
2011-01-19 07:28:31 -05:00
|
|
|
// Copyright: (c) 1999-2011 Vaclav Slavik, Guillermo Rodriguez Garcia, Gershon Elber, Troels K
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-12-15 17:38:02 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_IMAGGIF_H_
|
|
|
|
#define _WX_IMAGGIF_H_
|
|
|
|
|
|
|
|
#include "wx/image.h"
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxGIFHandler
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#if wxUSE_GIF
|
|
|
|
|
2011-01-28 02:27:34 -05:00
|
|
|
#define wxIMAGE_OPTION_GIF_COMMENT wxT("GifComment")
|
|
|
|
|
2011-01-19 07:28:31 -05:00
|
|
|
struct wxRGB;
|
|
|
|
struct GifHashTableType;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxImageArray; // anidecod.h
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxGIFHandler : public wxImageHandler
|
1999-12-15 17:38:02 -05:00
|
|
|
{
|
|
|
|
public:
|
2002-12-04 09:11:26 -05:00
|
|
|
inline wxGIFHandler()
|
|
|
|
{
|
|
|
|
m_name = wxT("GIF file");
|
|
|
|
m_extension = wxT("gif");
|
|
|
|
m_type = wxBITMAP_TYPE_GIF;
|
|
|
|
m_mime = wxT("image/gif");
|
2011-01-19 07:28:31 -05:00
|
|
|
m_hashTable = NULL;
|
2002-12-04 09:11:26 -05:00
|
|
|
}
|
1999-12-15 17:38:02 -05:00
|
|
|
|
|
|
|
#if wxUSE_STREAMS
|
2009-04-05 08:52:22 -04:00
|
|
|
virtual bool LoadFile(wxImage *image, wxInputStream& stream,
|
|
|
|
bool verbose = true, int index = -1);
|
|
|
|
virtual bool SaveFile(wxImage *image, wxOutputStream& stream,
|
|
|
|
bool verbose=true);
|
2009-06-01 07:43:36 -04:00
|
|
|
|
2011-01-19 07:28:31 -05:00
|
|
|
// Save animated gif
|
|
|
|
bool SaveAnimation(const wxImageArray& images, wxOutputStream *stream,
|
2011-01-28 02:27:34 -05:00
|
|
|
bool verbose = true, int delayMilliSecs = 1000);
|
2011-01-19 07:28:31 -05:00
|
|
|
|
2006-02-08 16:47:09 -05:00
|
|
|
protected:
|
2009-06-01 07:43:36 -04:00
|
|
|
virtual int DoGetImageCount(wxInputStream& stream);
|
2009-04-05 08:52:22 -04:00
|
|
|
virtual bool DoCanRead(wxInputStream& stream);
|
2011-01-19 07:28:31 -05:00
|
|
|
|
|
|
|
bool DoSaveFile(const wxImage&, wxOutputStream *, bool verbose,
|
|
|
|
bool first, int delayMilliSecs, bool loop,
|
|
|
|
const wxRGB *pal, int palCount,
|
2011-01-28 02:27:34 -05:00
|
|
|
int mask_index);
|
2009-04-05 08:52:22 -04:00
|
|
|
#endif // wxUSE_STREAMS
|
2011-01-19 07:28:31 -05:00
|
|
|
protected:
|
|
|
|
|
|
|
|
// Declarations for saving
|
2002-12-04 09:11:26 -05:00
|
|
|
|
2011-01-19 07:28:31 -05:00
|
|
|
unsigned long m_crntShiftDWord; /* For bytes decomposition into codes. */
|
|
|
|
int m_pixelCount;
|
|
|
|
struct GifHashTableType *m_hashTable;
|
|
|
|
wxInt16
|
|
|
|
m_EOFCode, /* The EOF LZ code. */
|
|
|
|
m_clearCode, /* The CLEAR LZ code. */
|
|
|
|
m_runningCode, /* The next code algorithm can generate. */
|
|
|
|
m_runningBits, /* The number of bits required to represent RunningCode. */
|
|
|
|
m_maxCode1, /* 1 bigger than max. possible code, in RunningBits bits. */
|
|
|
|
m_crntCode, /* Current algorithm code. */
|
|
|
|
m_crntShiftState; /* Number of bits in CrntShiftDWord. */
|
|
|
|
wxUint8 m_LZBuf[256]; /* Compressed input is buffered here. */
|
|
|
|
|
|
|
|
bool InitHashTable();
|
|
|
|
void ClearHashTable();
|
|
|
|
void InsertHashTable(unsigned long key, int code);
|
|
|
|
int ExistsHashTable(unsigned long key);
|
|
|
|
|
|
|
|
#if wxUSE_STREAMS
|
|
|
|
bool CompressOutput(wxOutputStream *, int code);
|
|
|
|
bool SetupCompress(wxOutputStream *, int bpp);
|
|
|
|
bool CompressLine(wxOutputStream *, const wxUint8 *line, int lineLen);
|
|
|
|
#endif
|
2011-01-28 02:27:34 -05:00
|
|
|
|
2002-12-04 09:11:26 -05:00
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxGIFHandler)
|
1999-12-15 17:38:02 -05:00
|
|
|
};
|
|
|
|
|
2009-04-05 08:52:22 -04:00
|
|
|
#endif // wxUSE_GIF
|
1999-12-15 17:38:02 -05:00
|
|
|
|
2009-04-05 08:52:22 -04:00
|
|
|
#endif // _WX_IMAGGIF_H_
|
1999-12-15 17:38:02 -05:00
|
|
|
|