imaggif.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/imaggif.h
  3. // Purpose: wxImage GIF handler
  4. // Author: Vaclav Slavik, Guillermo Rodriguez Garcia, Gershon Elber, Troels K
  5. // Copyright: (c) 1999-2011 Vaclav Slavik, Guillermo Rodriguez Garcia, Gershon Elber, Troels K
  6. // Licence: wxWindows licence
  7. /////////////////////////////////////////////////////////////////////////////
  8. #ifndef _WX_IMAGGIF_H_
  9. #define _WX_IMAGGIF_H_
  10. #include "wx/image.h"
  11. //-----------------------------------------------------------------------------
  12. // wxGIFHandler
  13. //-----------------------------------------------------------------------------
  14. #if wxUSE_GIF
  15. #define wxIMAGE_OPTION_GIF_COMMENT wxT("GifComment")
  16. struct wxRGB;
  17. struct GifHashTableType;
  18. class WXDLLIMPEXP_FWD_CORE wxImageArray; // anidecod.h
  19. class WXDLLIMPEXP_CORE wxGIFHandler : public wxImageHandler
  20. {
  21. public:
  22. inline wxGIFHandler()
  23. {
  24. m_name = wxT("GIF file");
  25. m_extension = wxT("gif");
  26. m_type = wxBITMAP_TYPE_GIF;
  27. m_mime = wxT("image/gif");
  28. m_hashTable = NULL;
  29. }
  30. #if wxUSE_STREAMS
  31. virtual bool LoadFile(wxImage *image, wxInputStream& stream,
  32. bool verbose = true, int index = -1);
  33. virtual bool SaveFile(wxImage *image, wxOutputStream& stream,
  34. bool verbose=true);
  35. // Save animated gif
  36. bool SaveAnimation(const wxImageArray& images, wxOutputStream *stream,
  37. bool verbose = true, int delayMilliSecs = 1000);
  38. protected:
  39. virtual int DoGetImageCount(wxInputStream& stream);
  40. virtual bool DoCanRead(wxInputStream& stream);
  41. bool DoSaveFile(const wxImage&, wxOutputStream *, bool verbose,
  42. bool first, int delayMilliSecs, bool loop,
  43. const wxRGB *pal, int palCount,
  44. int mask_index);
  45. #endif // wxUSE_STREAMS
  46. protected:
  47. // Declarations for saving
  48. unsigned long m_crntShiftDWord; /* For bytes decomposition into codes. */
  49. int m_pixelCount;
  50. struct GifHashTableType *m_hashTable;
  51. wxInt16
  52. m_EOFCode, /* The EOF LZ code. */
  53. m_clearCode, /* The CLEAR LZ code. */
  54. m_runningCode, /* The next code algorithm can generate. */
  55. m_runningBits, /* The number of bits required to represent RunningCode. */
  56. m_maxCode1, /* 1 bigger than max. possible code, in RunningBits bits. */
  57. m_crntCode, /* Current algorithm code. */
  58. m_crntShiftState; /* Number of bits in CrntShiftDWord. */
  59. wxUint8 m_LZBuf[256]; /* Compressed input is buffered here. */
  60. bool InitHashTable();
  61. void ClearHashTable();
  62. void InsertHashTable(unsigned long key, int code);
  63. int ExistsHashTable(unsigned long key);
  64. #if wxUSE_STREAMS
  65. bool CompressOutput(wxOutputStream *, int code);
  66. bool SetupCompress(wxOutputStream *, int bpp);
  67. bool CompressLine(wxOutputStream *, const wxUint8 *line, int lineLen);
  68. #endif
  69. private:
  70. DECLARE_DYNAMIC_CLASS(wxGIFHandler)
  71. };
  72. #endif // wxUSE_GIF
  73. #endif // _WX_IMAGGIF_H_