FLTK 1.4.0
Loading...
Searching...
No Matches
Fl_Anim_GIF_Image.H
1//
2// Fl_Anim_GIF_Image class header for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 2016-2023 by Christian Grabner <wcout@gmx.net>.
5//
6// This library is free software. Distribution and use rights are outlined in
7// the file "COPYING" which should have been included with this file. If this
8// file is missing or damaged, see the license at:
9//
10// https://www.fltk.org/COPYING.php
11//
12// Please see the following page on how to report bugs and issues:
13//
14// https://www.fltk.org/bugs.php
15//
16
17#ifndef Fl_Anim_Gif_Image_H
18#define Fl_Anim_Gif_Image_H
19
20// forward declarations
21class Fl_Image;
22class Fl_Widget;
23
24#include <FL/Fl_GIF_Image.H>
25
26// Load and display animated GIF images
27class FL_EXPORT Fl_Anim_GIF_Image : public Fl_GIF_Image {
28
29 class FrameInfo; // internal helper class
30
31public:
32
37 enum Flags {
44 DONT_START = 1,
51 DONT_RESIZE_CANVAS = 2,
58 DONT_SET_AS_IMAGE = 4,
67 OPTIMIZE_MEMORY = 8,
72 LOG_FLAG = 64,
77 DEBUG_FLAG = 128
78 };
79
80 // -- constructors and destructor
81 Fl_Anim_GIF_Image(const char *filename, Fl_Widget *canvas = 0, unsigned short flags = 0);
82 Fl_Anim_GIF_Image(const char* imagename, const unsigned char *data,
83 const size_t length, Fl_Widget *canvas = 0,
84 unsigned short flags = 0);
87
88 // -- file handling
89 bool load(const char *name, const unsigned char *imgdata=NULL, size_t imglength=0);
90 bool valid() const;
91
92 // -- getters and setters
93 void frame_uncache(bool uncache);
94 bool frame_uncache() const;
95 double delay(int frame_) const;
96 void delay(int frame, double delay);
97 void canvas(Fl_Widget *canvas, unsigned short flags = 0);
98 Fl_Widget *canvas() const;
99 int canvas_w() const;
100 int canvas_h() const;
101 bool is_animated() const;
102 const char *name() const;
103 void speed(double speed);
104 double speed() const;
105
106 // -- animation
107 int frames() const;
108 void frame(int frame);
109 int frame() const;
110 Fl_Image *image() const;
111 Fl_Image *image(int frame) const;
112 bool start();
113 bool stop();
114 bool next();
115
119 bool playing() const { return valid() && Fl::has_timeout(cb_animate, (void *)this); }
120
121 // -- image data
122 Fl_Anim_GIF_Image& resize(int w, int h);
123 Fl_Anim_GIF_Image& resize(double scale);
124 int frame_x(int frame) const;
125 int frame_y(int frame) const;
126 int frame_w(int frame) const;
127 int frame_h(int frame) const;
128
129 // -- overridden methods
130 void color_average(Fl_Color c, float i) FL_OVERRIDE;
131 Fl_Image *copy(int W, int H) const FL_OVERRIDE;
132 Fl_Image *copy() const { return Fl_Pixmap::copy(); }
133 void desaturate() FL_OVERRIDE;
134 void draw(int x, int y, int w, int h, int cx = 0, int cy = 0) FL_OVERRIDE;
135 void uncache() FL_OVERRIDE;
136
137 // -- debugging and logging
138 int debug() const;
139
140 // -- static methods
141 static int frame_count(const char *name, const unsigned char *imgdata = NULL, size_t imglength = 0);
142
151 static bool loop;
152
159 static double min_delay;
160
161protected:
162
163 bool next_frame();
164 void clear_frames();
165 void set_frame(int frame);
166
167 static void cb_animate(void *d);
168 void scale_frame();
169 void set_frame();
170 void on_frame_data(Fl_GIF_Image::GIF_FRAME &f) FL_OVERRIDE;
171 void on_extension_data(Fl_GIF_Image::GIF_FRAME &f) FL_OVERRIDE;
172
173private:
174
175 char *name_;
176 unsigned short flags_;
177 Fl_Widget *canvas_;
178 bool uncache_;
179 bool valid_;
180 int frame_; // current frame
181 double speed_;
182 FrameInfo *fi_;
183};
184
185#endif // Fl_Anim_Gif_Image_H
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition Enumerations.H:1101
The Fl_Anim_GIF_Image class supports loading, caching, and drawing of animated Compuserve GIFSM image...
Definition Fl_Anim_GIF_Image.H:27
Flags
When opening an Fl_Anim_GIF_Image there are some options that can be passed in a flags value.
Definition Fl_Anim_GIF_Image.H:37
The Fl_GIF_Image class supports loading, caching, and drawing of Compuserve GIFSM images.
Definition Fl_GIF_Image.H:29
Base class for image caching, scaling and drawing.
Definition Fl_Image.H:60
void desaturate() FL_OVERRIDE
The desaturate() method converts an image to grayscale.
Definition Fl_Pixmap.cxx:322
void color_average(Fl_Color c, float i) FL_OVERRIDE
The color_average() method averages the colors in the image with the provided FLTK color value.
Definition Fl_Pixmap.cxx:228
Fl_Widget is the base class for all widgets in FLTK.
Definition Fl_Widget.H:104
static int has_timeout(Fl_Timeout_Handler cb, void *data=0)
Returns true if the timeout exists and has not been called yet.
Definition Fl.cxx:342
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
Definition Fl_GIF_Image.H:61