anidecod.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/anidecod.h
  3. // Purpose: wxANIDecoder, ANI reader for wxImage and wxAnimation
  4. // Author: Francesco Montorsi
  5. // Copyright: (c) 2006 Francesco Montorsi
  6. // Licence: wxWindows licence
  7. /////////////////////////////////////////////////////////////////////////////
  8. #ifndef _WX_ANIDECOD_H
  9. #define _WX_ANIDECOD_H
  10. #include "wx/defs.h"
  11. #if wxUSE_STREAMS && (wxUSE_ICO_CUR || wxUSE_GIF)
  12. #include "wx/stream.h"
  13. #include "wx/image.h"
  14. #include "wx/animdecod.h"
  15. #include "wx/dynarray.h"
  16. class /*WXDLLIMPEXP_CORE*/ wxANIFrameInfo; // private implementation detail
  17. WX_DECLARE_EXPORTED_OBJARRAY(wxANIFrameInfo, wxANIFrameInfoArray);
  18. WX_DECLARE_EXPORTED_OBJARRAY(wxImage, wxImageArray);
  19. // --------------------------------------------------------------------------
  20. // wxANIDecoder class
  21. // --------------------------------------------------------------------------
  22. class WXDLLIMPEXP_CORE wxANIDecoder : public wxAnimationDecoder
  23. {
  24. public:
  25. // constructor, destructor, etc.
  26. wxANIDecoder();
  27. ~wxANIDecoder();
  28. virtual wxSize GetFrameSize(unsigned int frame) const;
  29. virtual wxPoint GetFramePosition(unsigned int frame) const;
  30. virtual wxAnimationDisposal GetDisposalMethod(unsigned int frame) const;
  31. virtual long GetDelay(unsigned int frame) const;
  32. virtual wxColour GetTransparentColour(unsigned int frame) const;
  33. // implementation of wxAnimationDecoder's pure virtuals
  34. virtual bool Load( wxInputStream& stream );
  35. bool ConvertToImage(unsigned int frame, wxImage *image) const;
  36. wxAnimationDecoder *Clone() const
  37. { return new wxANIDecoder; }
  38. wxAnimationType GetType() const
  39. { return wxANIMATION_TYPE_ANI; }
  40. private:
  41. // wxAnimationDecoder pure virtual:
  42. virtual bool DoCanRead( wxInputStream& stream ) const;
  43. // modifies current stream position (see wxAnimationDecoder::CanRead)
  44. // frames stored as wxImage(s): ANI files are meant to be used mostly for animated
  45. // cursors and thus they do not use any optimization to encode differences between
  46. // two frames: they are just a list of images to display sequentially.
  47. wxImageArray m_images;
  48. // the info about each image stored in m_images.
  49. // NB: m_info.GetCount() may differ from m_images.GetCount()!
  50. wxANIFrameInfoArray m_info;
  51. // this is the wxCURHandler used to load the ICON chunk of the ANI files
  52. static wxCURHandler sm_handler;
  53. wxDECLARE_NO_COPY_CLASS(wxANIDecoder);
  54. };
  55. #endif // wxUSE_STREAMS && (wxUSE_ICO_CUR || wxUSE_GIF)
  56. #endif // _WX_ANIDECOD_H