1999-12-15 22:38:02 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2009-04-05 12:52:22 +00:00
|
|
|
// Name: wx/imaggif.h
|
1999-12-15 22:38:02 +00:00
|
|
|
// Purpose: wxImage GIF handler
|
2011-01-19 12:28:31 +00:00
|
|
|
// Author: Vaclav Slavik, Guillermo Rodriguez Garcia, Gershon Elber, Troels K
|
|
|
|
// Copyright: (c) 1999-2011 Vaclav Slavik, Guillermo Rodriguez Garcia, Gershon Elber, Troels K
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1999-12-15 22:38:02 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_IMAGGIF_H_
|
|
|
|
#define _WX_IMAGGIF_H_
|
|
|
|
|
|
|
|
#include "wx/image.h"
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxGIFHandler
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#if wxUSE_GIF
|
|
|
|
|
2011-01-28 07:27:34 +00:00
|
|
|
#define wxIMAGE_OPTION_GIF_COMMENT wxT("GifComment")
|
|
|
|
|
2011-01-19 12:28:31 +00:00
|
|
|
struct wxRGB;
|
|
|
|
struct GifHashTableType;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxImageArray; // anidecod.h
|
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxGIFHandler : public wxImageHandler
|
1999-12-15 22:38:02 +00:00
|
|
|
{
|
|
|
|
public:
|
2002-12-04 14:11:26 +00: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 12:28:31 +00:00
|
|
|
m_hashTable = NULL;
|
2002-12-04 14:11:26 +00:00
|
|
|
}
|
1999-12-15 22:38:02 +00:00
|
|
|
|
|
|
|
#if wxUSE_STREAMS
|
2009-04-05 12:52:22 +00:00
|
|
|
virtual bool LoadFile(wxImage *image, wxInputStream& stream,
|
2014-03-30 00:02:23 +00:00
|
|
|
bool verbose = true, int index = -1) wxOVERRIDE;
|
2009-04-05 12:52:22 +00:00
|
|
|
virtual bool SaveFile(wxImage *image, wxOutputStream& stream,
|
2014-03-30 00:02:23 +00:00
|
|
|
bool verbose=true) wxOVERRIDE;
|
2009-06-01 11:43:36 +00:00
|
|
|
|
2011-01-19 12:28:31 +00:00
|
|
|
// Save animated gif
|
|
|
|
bool SaveAnimation(const wxImageArray& images, wxOutputStream *stream,
|
2011-01-28 07:27:34 +00:00
|
|
|
bool verbose = true, int delayMilliSecs = 1000);
|
2011-01-19 12:28:31 +00:00
|
|
|
|
2006-02-08 21:47:09 +00:00
|
|
|
protected:
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual int DoGetImageCount(wxInputStream& stream) wxOVERRIDE;
|
|
|
|
virtual bool DoCanRead(wxInputStream& stream) wxOVERRIDE;
|
2011-01-19 12:28:31 +00:00
|
|
|
|
|
|
|
bool DoSaveFile(const wxImage&, wxOutputStream *, bool verbose,
|
|
|
|
bool first, int delayMilliSecs, bool loop,
|
|
|
|
const wxRGB *pal, int palCount,
|
2011-01-28 07:27:34 +00:00
|
|
|
int mask_index);
|
2009-04-05 12:52:22 +00:00
|
|
|
#endif // wxUSE_STREAMS
|
2011-01-19 12:28:31 +00:00
|
|
|
protected:
|
|
|
|
|
|
|
|
// Declarations for saving
|
2002-12-04 14:11:26 +00:00
|
|
|
|
2011-01-19 12:28:31 +00: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 07:27:34 +00:00
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
private:
|
2015-04-23 11:49:01 +00:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxGIFHandler);
|
1999-12-15 22:38:02 +00:00
|
|
|
};
|
|
|
|
|
2009-04-05 12:52:22 +00:00
|
|
|
#endif // wxUSE_GIF
|
1999-12-15 22:38:02 +00:00
|
|
|
|
2009-04-05 12:52:22 +00:00
|
|
|
#endif // _WX_IMAGGIF_H_
|
1999-12-15 22:38:02 +00:00
|
|
|
|