Fl_Anim_GIF
 All Classes Functions Variables
Fl_Anim_GIF.H
1 //
2 // Copyright 2016-2019 Christian Grabner <wcout@gmx.net>
3 //
4 // Fl_Anim_GIF widget - FLTK animated GIF widget.
5 //
6 // Fl_Anim_GIF 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 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_H
18 #define Fl_Anim_GIF_H
19 
20 class Fl_Image;
21 class RGB_Image;
22 struct GIF_WHDR;
23 
24 #include <FL/Fl_Box.H>
25 
33 class Fl_Anim_GIF : public Fl_Box {
34  typedef Fl_Box Inherited;
35 
36  class FrameInfo;
37 
38 public:
54  Fl_Anim_GIF(int x_, int y_, int w_, int h_, const char *name_ = 0,
55  bool start_ = true, bool optimize_mem_ = false, int debug_ = 0);
56  Fl_Anim_GIF(int x_, int y_, const char *name_ = 0,
57  bool start_ = true, bool optimize_mem_ = false, int debug_ = 0);
62  ~Fl_Anim_GIF();
69  void autoresize(bool autoresize);
70  bool autoresize() const { return _autoresize; }
75  int canvas_w() const;
80  int canvas_h() const;
85  virtual void color_average(Fl_Color c_, float i_);
91  Fl_Anim_GIF *copy();
92  virtual Fl_Anim_GIF *copy(int W_, int H_);
97  int debug() const;
102  virtual void desaturate();
106  double delay(int frame_) const;
110  void delay(int frame_, double delay_);
116  int frame_x(int frame_) const;
117  int frame_y(int frame_) const;
123  int frame_w(int frame_) const;
124  int frame_h(int frame_) const;
128  int frames() const;
132  void frame(int frame_);
137  int frame() const;
141  Fl_Image *image() const;
145  Fl_Image *image(int frame_) const;
150  Fl_Anim_GIF& resize(int W_, int H_);
151  Fl_Anim_GIF& resize(double scale_);
157  bool load(const char *name_);
166  static bool loop;
173  static double min_delay;
177  const char *name() const;
178  bool playing() const { return _valid && !_stopped; }
189  void speed(double speed_);
190  double speed() const;
194  bool start();
198  bool stop();
207  void uncache(bool uncache_);
211  bool uncache() const;
217  bool valid() const;
218 public:
223  virtual void draw();
224  virtual void resize(int x_, int y_, int w_, int h_);
225 protected:
226  bool next_frame();
227  void clear_frames();
228  void set_frame(int frame_);
229 private:
230  static void cb_animate(void *d_);
231  static void cb_gl_frame(void *ctx_, GIF_WHDR *whdr_);
232  static void cb_gl_extension(void *ctx_, GIF_WHDR *whdr_);
233  void scale_frame(int frame_ = -1);
234 private:
235  Fl_Anim_GIF();
236  void onFrameLoaded(GIF_WHDR &whdr_);
237  void onExtensionLoaded(GIF_WHDR &whdr_);
238  void _init(const char*name_, bool start_, bool optimize_mem_, int debug_);
239 private:
240  char *_name;
241  bool _valid;
242  bool _uncache;
243  bool _stopped;
244  int _frame; // current frame
245  double _speed;
246  bool _autoresize;
247  FrameInfo *_fi;
248 };
249 
250 #endif // Fl_Anim_GIF_H
static double min_delay
Definition: Fl_Anim_GIF.H:173
int frame() const
Definition: Fl_Anim_GIF.cxx:772
Fl_Anim_GIF * copy()
Definition: Fl_Anim_GIF.cxx:672
bool valid() const
Definition: Fl_Anim_GIF.cxx:1006
bool load(const char *name_)
Definition: Fl_Anim_GIF.cxx:835
static bool loop
Definition: Fl_Anim_GIF.H:166
virtual void desaturate()
Definition: Fl_Anim_GIF.cxx:715
int debug() const
Definition: Fl_Anim_GIF.cxx:696
virtual void draw()
Definition: Fl_Anim_GIF.cxx:721
void autoresize(bool autoresize)
Definition: Fl_Anim_GIF.cxx:630
bool uncache() const
Definition: Fl_Anim_GIF.cxx:1001
Fl_Anim_GIF & resize(int W_, int H_)
Definition: Fl_Anim_GIF.cxx:907
bool start()
Definition: Fl_Anim_GIF.cxx:978
Fl_Image * image() const
Definition: Fl_Anim_GIF.cxx:805
bool stop()
Definition: Fl_Anim_GIF.cxx:989
const char * name() const
Definition: Fl_Anim_GIF.cxx:875
~Fl_Anim_GIF()
Definition: Fl_Anim_GIF.cxx:623
Definition: Fl_Anim_GIF.H:33
int canvas_w() const
Definition: Fl_Anim_GIF.cxx:641
int frames() const
Definition: Fl_Anim_GIF.cxx:767
virtual void color_average(Fl_Color c_, float i_)
Definition: Fl_Anim_GIF.cxx:659
int frame_w(int frame_) const
Definition: Fl_Anim_GIF.cxx:791
int canvas_h() const
Definition: Fl_Anim_GIF.cxx:646
int frame_x(int frame_) const
Definition: Fl_Anim_GIF.cxx:777
double delay(int frame_) const
Definition: Fl_Anim_GIF.cxx:701