Fl_Anim_GIF_Image
 All Classes Functions Variables Enumerations Enumerator
Fl_Anim_GIF_Image.H
1 //
2 // Copyright 2016-2019 Christian Grabner <wcout@gmx.net>
3 //
4 // Fl_Anim_GIF_Image class - FLTK animated GIF extension.
5 //
6 // Fl_Anim_GIF_Image is free software: you can redistribute it and/or modify it
7 // under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // Fl_Anim_GIF_Image is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 // See the GNU General Public License for more details:
15 // http://www.gnu.org/licenses/.
16 //
17 #ifndef Fl_Anim_Gif_Image_H
18 #define Fl_Anim_Gif_Image_H
19 
20 class Fl_Image;
21 class Fl_Widget;
22 
23 #include <FL/Fl_GIF_Image.H>
24 
36 class FL_EXPORT Fl_Anim_GIF_Image : public Fl_GIF_Image {
37  typedef Fl_GIF_Image Inherited;
38 public:
39 
40  class FrameInfo; // internal helper class
41 
46  enum Flags {
51  Start = 1,
58  DontResizeCanvas = 2,
65  DontSetAsImage = 4,
74  OptimizeMemory = 8,
79  Log = 64,
84  Debug = 128
85  };
93  Fl_Anim_GIF_Image(const char *name_, Fl_Widget *canvas_ = 0, unsigned short flags_ = 0);
95  virtual ~Fl_Anim_GIF_Image();
104  void canvas(Fl_Widget *canvas_, unsigned short flags_ = 0);
105  Fl_Widget *canvas() const;
110  int canvas_w() const;
115  int canvas_h() const;
120  virtual void color_average(Fl_Color c_, float i_);
126  virtual Fl_Image *copy(int W_, int H_);
127  int debug() const;
132  virtual void desaturate();
133  virtual void draw(int x_, int y_, int w_, int h_, int cx_ = 0, int cy_ = 0);
137  double delay(int frame_) const;
141  void delay(int frame_, double delay_);
145  int frames() const;
149  void frame(int frame_);
154  int frame() const;
158  Fl_Image *image() const;
162  Fl_Image *image(int frame_) const;
167  bool is_animated() const;
168  int frame_count(const char *name_);
177  void frame_uncache(bool uncache_);
181  bool frame_uncache() const;
187  bool load(const char *name_);
196  static bool loop;
203  static double min_delay;
207  const char *name() const;
211  bool start();
215  bool stop();
220  Fl_Anim_GIF_Image& resize(int W_, int H_);
221  Fl_Anim_GIF_Image& resize(double scale_);
227  void speed(double speed_);
228  double speed() const;
232  virtual void uncache();
238  bool valid() const;
244  int frame_x(int frame_) const;
245  int frame_y(int frame_) const;
251  int frame_w(int frame_) const;
252  int frame_h(int frame_) const;
253 protected:
254  bool next_frame();
255  void clear_frames();
256  void set_frame(int frame_);
257 private:
258  static void cb_animate(void *d_);
259  void scale_frame();
260 private:
261  char *_name;
262  unsigned short _flags;
263  Fl_Widget *_canvas;
264  bool _uncache;
265  bool _valid;
266  int _frame; // current frame
267  double _speed;
268  FrameInfo *_fi;
269 };
270 
271 #endif // Fl_Anim_Gif_Image_H
static double min_delay
Definition: Fl_Anim_GIF_Image.H:203
Flags
Definition: Fl_Anim_GIF_Image.H:46
static bool loop
Definition: Fl_Anim_GIF_Image.H:196
Definition: Fl_GIF_Image.H:31
Definition: Fl_Anim_GIF_Image.H:36