FLTK 1.3.0
Fl_Shared_Image Class Reference

This class supports caching, loading, and drawing of image files. More...

#include <Fl_Shared_Image.H>

Inheritance diagram for Fl_Shared_Image:
Fl_Image

List of all members.

Public Member Functions

virtual void color_average (Fl_Color c, float i)
 The color_average() method averages the colors in the image with the FLTK color value c.
virtual Fl_Imagecopy (int W, int H)
 The copy() method creates a copy of the specified image.
Fl_Imagecopy ()
 The copy() method creates a copy of the specified image.
virtual void desaturate ()
 The desaturate() method converts an image to grayscale.
virtual void draw (int X, int Y, int W, int H, int cx, int cy)
 Draws the image with a bounding box.
void draw (int X, int Y)
 Draws the image.
const char * name ()
 Returns the filename of the shared image.
int refcount ()
 Returns the number of references of this shared image.
void release ()
 Releases and possibly destroys (if refcount <=0) a shared image.
void reload ()
 Reloads the shared image from disk.
virtual void uncache ()
 If the image has been cached for display, delete the cache data.

Static Public Member Functions

static void add_handler (Fl_Shared_Handler f)
 Adds a shared image handler, which is basically a test function for adding new formats.
static Fl_Shared_Imagefind (const char *n, int W=0, int H=0)
 Finds a shared image from its named and size specifications.
static Fl_Shared_Imageget (const char *n, int W=0, int H=0)
 Find or load an image that can be shared by multiple widgets.
static Fl_Shared_Image ** images ()
 Returns the Fl_Shared_Image* array.
static int num_images ()
 Returns the total number of shared images in the array.
static void remove_handler (Fl_Shared_Handler f)
 Removes a shared image handler.

Protected Member Functions

void add ()
 Fl_Shared_Image ()
 Creates an empty shared image.
 Fl_Shared_Image (const char *n, Fl_Image *img=0)
 Creates a shared image from its filename and its corresponding Fl_Image* img.
void update ()
virtual ~Fl_Shared_Image ()
 The destructor free all memory and server resources that are used by the image.

Static Protected Member Functions

static int compare (Fl_Shared_Image **i0, Fl_Shared_Image **i1)

Protected Attributes

int alloc_image_
Fl_Imageimage_
const char * name_
int original_
int refcount_

Static Protected Attributes

static int alloc_handlers_ = 0
static int alloc_images_ = 0
static Fl_Shared_Handler * handlers_ = 0
static Fl_Shared_Image ** images_ = 0
static int num_handlers_ = 0
static int num_images_ = 0

Friends

class Fl_JPEG_Image
class Fl_PNG_Image

Detailed Description

This class supports caching, loading, and drawing of image files.

Most applications will also want to link against the fltk_images library and call the fl_register_images() function to support standard image formats such as BMP, GIF, JPEG, and PNG.


Constructor & Destructor Documentation

Creates an empty shared image.

The constructors create a new shared image record in the image cache.

The constructors are protected and cannot be used directly from a program. Use the get() method instead.

Fl_Shared_Image::Fl_Shared_Image ( const char *  n,
Fl_Image img = 0 
) [protected]

Creates a shared image from its filename and its corresponding Fl_Image* img.

The constructors create a new shared image record in the image cache.

The constructors are protected and cannot be used directly from a program. Use the get() method instead.

Fl_Shared_Image::~Fl_Shared_Image ( ) [protected, virtual]

The destructor free all memory and server resources that are used by the image.

The destructor is protected and cannot be used directly from a program. Use the Fl_Shared_Image::release() method instead.


Member Function Documentation

void Fl_Shared_Image::color_average ( Fl_Color  c,
float  i 
) [virtual]

The color_average() method averages the colors in the image with the FLTK color value c.

The i argument specifies the amount of the original image to combine with the color, so a value of 1.0 results in no color blend, and a value of 0.0 results in a constant image of the specified color. The original image data is not altered by this method.

Reimplemented from Fl_Image.

Fl_Image * Fl_Shared_Image::copy ( int  W,
int  H 
) [virtual]

The copy() method creates a copy of the specified image.

If the width and height are provided, the image is resized to the specified size. The image should be deleted (or in the case of Fl_Shared_Image, released) when you are done with it.

Reimplemented from Fl_Image.

The copy() method creates a copy of the specified image.

If the width and height are provided, the image is resized to the specified size. The image should be deleted (or in the case of Fl_Shared_Image, released) when you are done with it.

Reimplemented from Fl_Image.

void Fl_Shared_Image::desaturate ( ) [virtual]

The desaturate() method converts an image to grayscale.

If the image contains an alpha channel (depth = 4), the alpha channel is preserved. This method does not alter the original image data.

Reimplemented from Fl_Image.

void Fl_Shared_Image::draw ( int  X,
int  Y,
int  W,
int  H,
int  cx,
int  cy 
) [virtual]

Draws the image with a bounding box.

This form specifies a bounding box for the image, with the origin (upper-lefthand corner) of the image offset by the cx and cy arguments.

Reimplemented from Fl_Image.

void Fl_Shared_Image::draw ( int  X,
int  Y 
) [inline]

Draws the image.

This form specifies the upper-lefthand corner of the image.

Reimplemented from Fl_Image.

Fl_Shared_Image * Fl_Shared_Image::get ( const char *  n,
int  W = 0,
int  H = 0 
) [static]

Find or load an image that can be shared by multiple widgets.

Gets a shared image, if it exists already ; it will return it. If it does not exist or if it exist but with other size, then the existing image is deleted and replaced by a new image from the n filename of the proper dimension. If n is not a valid image filename, then get() will return NULL.

Shared JPEG and PNG images can also be created from memory by using their named memory access constructor.

Parameters:
nname of the image
W,Hdesired size
See also:
Fl_Shared_Image::find(const char *n, int W, int H)
Fl_Shared_Image::release()
Fl_JPEG_Image::Fl_JPEG_Image(const char *name, const unsigned char *data)
Fl_PNG_Image::Fl_PNG_Image (const char *name_png, const unsigned char *buffer, int maxsize)
int Fl_Shared_Image::num_images ( ) [static]

Returns the total number of shared images in the array.

int Fl_Shared_Image::refcount ( ) [inline]

Returns the number of references of this shared image.

When reference is below 1, the image is deleted.

Releases and possibly destroys (if refcount <=0) a shared image.

In the latter case, it will reorganize the shared image array so that no hole will occur.

void Fl_Shared_Image::uncache ( ) [virtual]

If the image has been cached for display, delete the cache data.

This allows you to change the data used for the image and then redraw it without recreating an image object.

Reimplemented from Fl_Image.


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