Fl_Anim_GIF_Image
 All Classes Functions Variables Enumerations Enumerator
Fl_Anim_GIF_Image Class Reference

#include <Fl_Anim_GIF_Image.H>

Inheritance diagram for Fl_Anim_GIF_Image:
Fl_GIF_Image

Public Types

enum  Flags {
  Start = 1, DontResizeCanvas = 2, DontSetAsImage = 4, OptimizeMemory = 8,
  Log = 64, Debug = 128
}
 

Public Member Functions

 Fl_Anim_GIF_Image (const char *name_, Fl_Widget *canvas_=0, unsigned short flags_=0)
 
void canvas (Fl_Widget *canvas_, unsigned short flags_=0)
 
Fl_Widget * canvas () const
 
int canvas_w () const
 
int canvas_h () const
 
virtual void color_average (Fl_Color c_, float i_)
 
virtual Fl_Image * copy (int W_, int H_)
 
int debug () const
 
virtual void desaturate ()
 
virtual void draw (int x_, int y_, int w_, int h_, int cx_=0, int cy_=0)
 
double delay (int frame_) const
 
void delay (int frame_, double delay_)
 
int frames () const
 
void frame (int frame_)
 
int frame () const
 
Fl_Image * image () const
 
Fl_Image * image (int frame_) const
 
bool is_animated () const
 
int frame_count (const char *name_)
 
void frame_uncache (bool uncache_)
 
bool frame_uncache () const
 
bool load (const char *name_)
 
const char * name () const
 
bool start ()
 
bool stop ()
 
Fl_Anim_GIF_Imageresize (int W_, int H_)
 
Fl_Anim_GIF_Imageresize (double scale_)
 
void speed (double speed_)
 
double speed () const
 
virtual void uncache ()
 
bool valid () const
 
int frame_x (int frame_) const
 
int frame_y (int frame_) const
 
int frame_w (int frame_) const
 
int frame_h (int frame_) const
 
- Public Member Functions inherited from Fl_GIF_Image
 Fl_GIF_Image (const char *filename)
 

Static Public Attributes

static bool loop = true
 
static double min_delay = 0.
 
- Static Public Attributes inherited from Fl_GIF_Image
static bool animate = false
 

Protected Member Functions

bool next_frame ()
 
void clear_frames ()
 
void set_frame (int frame_)
 

Additional Inherited Members

- Static Public Member Functions inherited from Fl_GIF_Image
static bool is_animated (const char *name_)
 

Detailed Description

The Fl_Anim_GIF_Image 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.

You must supply an FLTK widget as "container" in order to see the animation by specifying it in the constructor or later using the canvas() method.

Member Enumeration Documentation

When opening a Fl_Anim_GIF_Image there are some options that can be passed in a 'flags' value.

Enumerator
Start 

This flag indicates to the loader that it should start the animation immediately after successful load.

DontResizeCanvas 

This flag indicates to the loader that it should not resize the canvas widget of the animation to the dimensions of the animation, which is the default. Needed for special use cases

DontSetAsImage 

This flag indicates to the loader that it should not set the animation as image() member of the canvas widget, which is the default. Needed for special use cases.

OptimizeMemory 

Often frames change just a small area of the animation canvas. This flag indicates to the loader to try using less memory, by storing frame data not as canvas-sized images but use the sizes defined in the GIF file. The drawbacks are higher cpu usage during playback and maybe minor artefacts when resized.

Log 

This flag can be used to print informations about the decoding process to the console.

Debug 

This flag can be used to print even more informations about the decoding process to the console.

Constructor & Destructor Documentation

Fl_Anim_GIF_Image::Fl_Anim_GIF_Image ( const char *  name_,
Fl_Widget *  canvas_ = 0,
unsigned short  flags_ = 0 
)

The constructor creates an new animated gif object from the given file. Optionally it applies the canvas() method after successful load. If 'Start' is specified in the 'flags' parameter it calls start() after successful load.

Member Function Documentation

void Fl_Anim_GIF_Image::canvas ( Fl_Widget *  canvas_,
unsigned short  flags_ = 0 
)

The canvas() method sets or gets the current widget, that is used for display of the frame images. The flags parameter specifies wheather the canvas widget is resized to the animation dimensions and/or its image() method will be used to set the current frame image during animation.

int Fl_Anim_GIF_Image::canvas_h ( ) const

Return the width and height of the animation canvas as specified in the file header

int Fl_Anim_GIF_Image::canvas_w ( ) const

Return the width and height of the animation canvas as specified in the file header

void Fl_Anim_GIF_Image::color_average ( Fl_Color  c_,
float  i_ 
)
virtual

The color_average() method applies the specified color_average to all frames of the animation.

Fl_Image * Fl_Anim_GIF_Image::copy ( int  W_,
int  H_ 
)
virtual

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.

double Fl_Anim_GIF_Image::delay ( int  frame_) const

Return the delay of frame 'frame_' [0-frames() -1] in seconds

void Fl_Anim_GIF_Image::delay ( int  frame_,
double  delay_ 
)

Set the delay of frame 'frame_' [0-frames() -1] in seconds

void Fl_Anim_GIF_Image::desaturate ( )
virtual

The desaturate() method applies desaturate() to all frames of the animation.

void Fl_Anim_GIF_Image::frame ( int  frame_)

Set the current frame in the range index [0-frames() -1]

int Fl_Anim_GIF_Image::frame ( ) const

Return the current frame in the range index [0-frames() -1] or -1 if the image has no frames.

void Fl_Anim_GIF_Image::frame_uncache ( bool  uncache_)

Use frame_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_Image::frame_uncache ( ) const

Return the active frame_uncache() setting.

int Fl_Anim_GIF_Image::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_Image::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_Image::frames ( ) const

Return the number of frames.

Fl_Image * Fl_Anim_GIF_Image::image ( ) const

Return the current frame image.

Fl_Image * Fl_Anim_GIF_Image::image ( int  frame_) const

Return the frame image of frame 'frame_'

bool Fl_Anim_GIF_Image::is_animated ( ) const

The is_animated() method is just a convenience method for testing the valid flag and the frame count beeing greater 1.

bool Fl_Anim_GIF_Image::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_Image::name ( ) const

Return the name of the played file as specified in the constructor.

Fl_Anim_GIF_Image & Fl_Anim_GIF_Image::resize ( int  W_,
int  H_ 
)

The resize() method resizes the image to the specified size, replacing the current image.

void Fl_Anim_GIF_Image::speed ( double  speed_)

The speed() method changes the playing speed to speed_ x original speed. E.g. to play at half speed call it with 0.5, for double speed with 2.

bool Fl_Anim_GIF_Image::start ( )

The start() method (re-)starts the playing of the frames.

bool Fl_Anim_GIF_Image::stop ( )

The stop() method stops the playing of the frames.

void Fl_Anim_GIF_Image::uncache ( )
virtual

Uncache all cached image data now. Re-implemented from Fl_Pixmap.

bool Fl_Anim_GIF_Image::valid ( ) const

The valid() method returns if the class has successfully loaded and the image has at least one frame.

Member Data Documentation

bool Fl_Anim_GIF_Image::loop = true
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.

double Fl_Anim_GIF_Image::min_delay = 0.
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_Image objects.


The documentation for this class was generated from the following files: