FLTK 1.4.4

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
21 class Fl_Image;
22 class Fl_Widget;
23
24#include <FL/Fl_GIF_Image.H>
25
26// Load and display animated GIF images
27 class FL_EXPORT Fl_Anim_GIF_Image : public Fl_GIF_Image {
28
29 class FrameInfo; // internal helper class
30
31 public:
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);
85 Fl_Anim_GIF_Image();
86 ~Fl_Anim_GIF_Image() FL_OVERRIDE;
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
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition Enumerations.H:1120
Fl_Anim_GIF_Image
The Fl_Anim_GIF_Image class supports loading, caching, and drawing of animated Compuserve GIFSM image...
Definition Fl_Anim_GIF_Image.H:27
Fl_Anim_GIF_Image::Fl_Anim_GIF_Image
Fl_Anim_GIF_Image(const char *filename, Fl_Widget *canvas=0, unsigned short flags=0)
Load an animated GIF image from a file.
Definition Fl_Anim_GIF_Image.cxx:522
Fl_Anim_GIF_Image::Flags
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
Fl_Anim_GIF_Image::OPTIMIZE_MEMORY
@ OPTIMIZE_MEMORY
Often frames change just a small area of the animation canvas.
Definition Fl_Anim_GIF_Image.H:67
Fl_Anim_GIF_Image::DONT_SET_AS_IMAGE
@ DONT_SET_AS_IMAGE
This flag indicates to the loader that it should not set the animation as image() member of the canva...
Definition Fl_Anim_GIF_Image.H:58
Fl_Anim_GIF_Image::DEBUG_FLAG
@ DEBUG_FLAG
This flag can be used to print even more informations about the decoding process to the console.
Definition Fl_Anim_GIF_Image.H:77
Fl_Anim_GIF_Image::DONT_START
@ DONT_START
This flag indicates to the loader that it should not start the animation immediately after successful...
Definition Fl_Anim_GIF_Image.H:44
Fl_Anim_GIF_Image::LOG_FLAG
@ LOG_FLAG
This flag can be used to print informations about the decoding process to the console.
Definition Fl_Anim_GIF_Image.H:72
Fl_Anim_GIF_Image::DONT_RESIZE_CANVAS
@ DONT_RESIZE_CANVAS
This flag indicates to the loader that it should not resize the canvas widget of the animation to the...
Definition Fl_Anim_GIF_Image.H:51
Fl_Anim_GIF_Image::valid
bool valid() const
Check if animation is valid.
Definition Fl_Anim_GIF_Image.cxx:1287
Fl_Anim_GIF_Image::min_delay
static double min_delay
The min_delay value can be used to set a minimum value for the frame delay for playback.
Definition Fl_Anim_GIF_Image.H:159
Fl_Anim_GIF_Image::loop
static bool loop
The loop flag can be used to (dis-)allow loop count.
Definition Fl_Anim_GIF_Image.H:151
Fl_Anim_GIF_Image::frame
void frame(int frame)
Set the current frame.
Definition Fl_Anim_GIF_Image.cxx:857
Fl_Anim_GIF_Image::playing
bool playing() const
Return if the animation is currently running or stopped.
Definition Fl_Anim_GIF_Image.H:119
Fl_GIF_Image::Fl_GIF_Image
Fl_GIF_Image(const char *filename)
This constructor loads a GIF image from the given file.
Definition Fl_GIF_Image.cxx:133
Fl_Image
Base class for image caching, scaling and drawing.
Definition Fl_Image.H:60
Fl_Image::d
void d(int D)
Sets the current image depth.
Definition Fl_Image.H:97
Fl_Image::copy
Fl_Image * copy() const
Creates a copy of the image in the same size.
Definition Fl_Image.H:266
Fl_Pixmap::desaturate
void desaturate() FL_OVERRIDE
The desaturate() method converts an image to grayscale.
Definition Fl_Pixmap.cxx:322
Fl_Pixmap::color_average
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
Fl_Widget is the base class for all widgets in FLTK.
Definition Fl_Widget.H:112
Fl::has_timeout
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:344
FL_OVERRIDE
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
Fl_GIF_Image::GIF_FRAME
Definition Fl_GIF_Image.H:61