Fl_Anim_GIF
|
#include <Fl_Anim_GIF.H>
Inherits Fl_Box.
Public Member Functions | |
Fl_Anim_GIF (int x_, int y_, int w_, int h_, const char *name_=0, bool start_=true, bool optimize_mem_=false, int debug_=0) | |
Fl_Anim_GIF (int x_, int y_, const char *name_=0, bool start_=true, bool optimize_mem_=false, int debug_=0) | |
~Fl_Anim_GIF () | |
void | autoresize (bool autoresize) |
bool | autoresize () const |
int | canvas_w () const |
int | canvas_h () const |
virtual void | color_average (Fl_Color c_, float i_) |
Fl_Anim_GIF * | copy () |
virtual Fl_Anim_GIF * | copy (int W_, int H_) |
int | debug () const |
virtual void | desaturate () |
double | delay (int frame_) const |
void | delay (int frame_, double delay_) |
int | frame_x (int frame_) const |
int | frame_y (int frame_) const |
int | frame_w (int frame_) const |
int | frame_h (int frame_) const |
int | frames () const |
void | frame (int frame_) |
int | frame () const |
Fl_Image * | image () const |
Fl_Image * | image (int frame_) const |
Fl_Anim_GIF & | resize (int W_, int H_) |
Fl_Anim_GIF & | resize (double scale_) |
bool | load (const char *name_) |
const char * | name () const |
bool | playing () const |
void | speed (double speed_) |
double | speed () const |
bool | start () |
bool | stop () |
void | uncache (bool uncache_) |
bool | uncache () const |
bool | valid () const |
virtual void | draw () |
virtual void | resize (int x_, int y_, int w_, int h_) |
Static Public Attributes | |
static bool | loop = true |
static double | min_delay = 0. |
Protected Member Functions | |
bool | next_frame () |
void | clear_frames () |
void | set_frame (int frame_) |
The Fl_Anim_GIF class supports loading, caching, and drawing of animated Compuserve GIFSM images. The class loads all images contained in the file and animates them by cycling through them as defined by the delay times in the image file.
Fl_Anim_GIF::Fl_Anim_GIF | ( | int | x_, |
int | y_, | ||
int | w_, | ||
int | h_, | ||
const char * | name_ = 0 , |
||
bool | start_ = true , |
||
bool | optimize_mem_ = false , |
||
int | debug_ = 0 |
||
) |
The constructor creates an new animated gif object from the given file. If 'start_=true' is specified as parameter (which is the default), it calls start() after successful load. If 'optimize_mem_=true' is specified as parameter (default: false) the loader tries using less memory, by storing frame data not as canvas-sized images but using the sizes defined in the GIF file. The drawbacks are higher cpu usage during playback and maybe minor artefacts when resized. The 'debug_' flag has been used during devolpment of this class, and kept afterwards, as it may still be useful. It is off by default.
Fl_Anim_GIF::~Fl_Anim_GIF | ( | ) |
The destructor stops a running animation and releases all resources.
void Fl_Anim_GIF::autoresize | ( | bool | autoresize | ) |
The autoresize flag sets the behaviour, when the underlying Fl_Box widget is resized by FLTK (e.g. when the window is resizable and is resized by the user). If the value is on, the image is auto-resized according the new Fl_Box dimensions. The default is off i.e. the image keeps it's dimensions.
int Fl_Anim_GIF::canvas_h | ( | ) | const |
Return the width and height of the animation canvas as specified in the file header
int Fl_Anim_GIF::canvas_w | ( | ) | const |
Return the width and height of the animation canvas as specified in the file header
|
virtual |
The color_average() method applies the specified color_average to all frames of the animation.
Fl_Anim_GIF * Fl_Anim_GIF::copy | ( | ) |
The virtual copy() method makes a copy of the animated image and resizes all of its frame images to W x H using the current resize method.
int Fl_Anim_GIF::debug | ( | ) | const |
The debug() method returns if the class has set the debug option in it's constructor.
double Fl_Anim_GIF::delay | ( | int | frame_ | ) | const |
Return the delay of frame 'frame_' [0-frames() -1]
in seconds
void Fl_Anim_GIF::delay | ( | int | frame_, |
double | delay_ | ||
) |
Set the delay of frame 'frame_' [0-frames() -1]
in seconds
|
virtual |
The desaturate() method applies desaturate() to all frames of the animation.
void Fl_Anim_GIF::frame | ( | int | frame_ | ) |
Set the current frame in the range index [0-frames() -1]
int Fl_Anim_GIF::frame | ( | ) | const |
Return the current frame in the range index [0-frames() -1]
or -1 if the image has no frames.
int Fl_Anim_GIF::frame_w | ( | int | frame_ | ) | const |
Return the frame dimensions of frame 'frame_'. Usefull only if loaded with 'optimize_mem' and the animation also has size optimized frames.
int Fl_Anim_GIF::frame_x | ( | int | frame_ | ) | const |
Return the frame position of frame 'frame_' Usefull only if loaded with 'optimize_mem' and the animation also has size optimized frames.
int Fl_Anim_GIF::frames | ( | ) | const |
Return the number of frames.
Fl_Image * Fl_Anim_GIF::image | ( | ) | const |
Return the current frame image.
Fl_Image * Fl_Anim_GIF::image | ( | int | frame_ | ) | const |
Return the frame image of frame 'frame_'
bool Fl_Anim_GIF::load | ( | const char * | name_ | ) |
The load() method is either used from the constructor to load the image from the given file, or to re-load an existing animation from another file.
const char * Fl_Anim_GIF::name | ( | ) | const |
Return the name of the played file as specified in the constructor.
Fl_Anim_GIF & Fl_Anim_GIF::resize | ( | int | W_, |
int | H_ | ||
) |
The resize() method resizes the image to the specified size, replacing the current image.
void Fl_Anim_GIF::speed | ( | double | speed_ | ) |
bool Fl_Anim_GIF::start | ( | ) |
The start() method (re-)starts the playing of the frames.
bool Fl_Anim_GIF::stop | ( | ) |
The stop() method stops the playing of the frames.
void Fl_Anim_GIF::uncache | ( | bool | uncache_ | ) |
Use uncache() to set or forbid frame image uncaching. If frame uncaching is set, frame images are not offscreen cached for re-use and will be re-created every time they are displayed. This saves a lot of memory on the expense of cpu usage and should to be carefully considered. Per default frame caching will be done.
bool Fl_Anim_GIF::uncache | ( | ) | const |
Return the active uncache() setting.
bool Fl_Anim_GIF::valid | ( | ) | const |
The valid() method returns if the class has successfully loaded and the image has at least one frame.
|
static |
The loop flag can be used to (dis-)allow loop count. If set (which is the default), the animation will be stopped after the number of repeats specified in the GIF file (typically this count is set to 'forever' anyway). If cleared the animation will always be 'forever', regardless of what is specified in the GIF file.
|
static |
The min_delay value can be used to set a minimum value for the frame delay for playback. This is to prevent cpu hogs caused by images with very low delay rates. This is a global value for all Fl_Anim_GIF objects.