1999-08-18 02:28:59 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: gifdecod.h
|
|
|
|
// Purpose: wxGIFDecoder, GIF reader for wxImage and wxAnimation
|
|
|
|
// Author: Guillermo Rodriguez Garcia <guille@iies.es>
|
1999-08-24 18:13:26 -04:00
|
|
|
// Version: 3.02
|
1999-09-09 18:12:08 -04:00
|
|
|
// CVS-ID: $Id$
|
|
|
|
// Copyright: (c) 1999 Guillermo Rodriguez Garcia
|
1999-08-18 02:28:59 -04:00
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_GIFDECOD_H
|
|
|
|
#define _WX_GIFDECOD_H
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface "gifdecod.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/setup.h"
|
|
|
|
|
1999-09-09 18:12:08 -04:00
|
|
|
#if wxUSE_STREAMS && wxUSE_GIF
|
|
|
|
|
1999-08-18 02:28:59 -04:00
|
|
|
#include "wx/stream.h"
|
|
|
|
#include "wx/image.h"
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _IMAGEN
|
|
|
|
{
|
|
|
|
unsigned int w; /* width */
|
|
|
|
unsigned int h; /* height */
|
|
|
|
unsigned int left; /* x coord (in logical screen) */
|
|
|
|
unsigned int top; /* y coord (in logical screen) */
|
|
|
|
int transparent; /* transparent color (-1 = none) */
|
1999-08-24 18:13:26 -04:00
|
|
|
int disposal; /* disposal method (-1 = unspecified) */
|
1999-08-18 02:28:59 -04:00
|
|
|
long delay; /* delay in ms (-1 = unused) */
|
|
|
|
unsigned char *p; /* bitmap */
|
|
|
|
unsigned char *pal; /* palette */
|
|
|
|
struct _IMAGEN *next; /* next image */
|
|
|
|
struct _IMAGEN *prev; /* prev image */
|
|
|
|
} IMAGEN;
|
|
|
|
|
|
|
|
|
|
|
|
/* disposal method */
|
|
|
|
#define D_UNSPECIFIED -1 /* not specified */
|
|
|
|
#define D_DONOTDISPOSE 0 /* do not dispose */
|
|
|
|
#define D_TOBACKGROUND 1 /* restore to background colour */
|
|
|
|
#define D_TOPREVIOUS 2 /* restore to previous image */
|
|
|
|
|
|
|
|
/* error codes */
|
|
|
|
#define E_OK 0 /* everything was OK */
|
1999-09-09 18:12:08 -04:00
|
|
|
#define E_FORMATO 1 /* error in gif header */
|
|
|
|
#define E_MEMORIA 2 /* error allocating memory */
|
1999-08-18 02:28:59 -04:00
|
|
|
|
1999-09-13 09:16:28 -04:00
|
|
|
class WXDLLEXPORT wxGIFDecoder
|
1999-08-18 02:28:59 -04:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
/* logical screen */
|
|
|
|
unsigned int m_screenw; /* logical screen width */
|
|
|
|
unsigned int m_screenh; /* logical screen height */
|
|
|
|
int m_background; /* background color (-1 = none) */
|
|
|
|
|
|
|
|
/* image data */
|
|
|
|
bool m_anim; /* animated GIF */
|
|
|
|
int m_nimages; /* number of images */
|
|
|
|
int m_image; /* current image */
|
|
|
|
IMAGEN *m_pimage; /* pointer to current image */
|
|
|
|
IMAGEN *m_pfirst; /* pointer to first image */
|
|
|
|
IMAGEN *m_plast; /* pointer to last image */
|
|
|
|
|
|
|
|
/* decoder state vars */
|
|
|
|
int m_restbits; /* remaining valid bits */
|
|
|
|
unsigned int m_restbyte; /* remaining bytes in this block */
|
|
|
|
unsigned int m_lastbyte; /* last byte read */
|
|
|
|
|
|
|
|
wxInputStream *m_f; /* input file */
|
|
|
|
|
|
|
|
private:
|
|
|
|
int getcode(int bits, int abfin);
|
|
|
|
int dgif(IMAGEN *img, int interl, int bits);
|
|
|
|
|
|
|
|
public:
|
|
|
|
// constructor, destructor, etc.
|
|
|
|
wxGIFDecoder(wxInputStream *s, bool anim = FALSE);
|
|
|
|
~wxGIFDecoder();
|
1999-08-24 18:13:26 -04:00
|
|
|
bool CanRead();
|
1999-08-18 02:28:59 -04:00
|
|
|
int ReadGIF();
|
|
|
|
void Destroy();
|
|
|
|
|
|
|
|
// convert current frame to wxImage
|
|
|
|
bool ConvertToImage(wxImage *image) const;
|
|
|
|
|
|
|
|
// get data of current frame
|
|
|
|
int GetFrameIndex() const;
|
|
|
|
unsigned char* GetData() const;
|
|
|
|
unsigned char* GetPalette() const;
|
|
|
|
unsigned int GetWidth() const;
|
|
|
|
unsigned int GetHeight() const;
|
|
|
|
unsigned int GetLeft() const;
|
|
|
|
unsigned int GetTop() const;
|
|
|
|
int GetDisposalMethod() const;
|
|
|
|
int GetTransparentColour() const;
|
|
|
|
long GetDelay() const;
|
|
|
|
|
|
|
|
// get global data
|
|
|
|
unsigned int GetLogicalScreenWidth() const;
|
|
|
|
unsigned int GetLogicalScreenHeight() const;
|
|
|
|
int GetBackgroundColour() const;
|
|
|
|
int GetNumberOfFrames() const;
|
|
|
|
bool IsAnimation() const;
|
|
|
|
|
|
|
|
// move through the animation
|
|
|
|
bool GoFirstFrame();
|
|
|
|
bool GoLastFrame();
|
|
|
|
bool GoNextFrame(bool cyclic = FALSE);
|
|
|
|
bool GoPrevFrame(bool cyclic = FALSE);
|
|
|
|
bool GoFrame(int which);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-09-09 18:12:08 -04:00
|
|
|
#endif // wxUSE_STREAM && wxUSE_GIF
|
1999-08-18 02:28:59 -04:00
|
|
|
#endif // _WX_GIFDECOD_H
|
|
|
|
|