fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
  SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation)  

Fl_Shared_Image Class Reference

#include <Fl_Shared_Image.H>

Inheritance diagram for Fl_Shared_Image:
Collaboration diagram for Fl_Shared_Image:

List of all members.

Public Member Functions

const char * name ()
int refcount ()
void release ()
void reload ()
virtual Fl_Imagecopy (int W, int H)
Fl_Imagecopy ()
virtual void color_average (Fl_Color c, float i)
virtual void desaturate ()
virtual void draw (int X, int Y, int W, int H, int cx, int cy)
void draw (int X, int Y)
virtual void uncache ()

Static Public Member Functions

static Fl_Shared_Imagefind (const char *n, int W=0, int H=0)
static Fl_Shared_Imageget (const char *n, int W=0, int H=0)
static Fl_Shared_Image ** images ()
static int num_images ()
static void add_handler (Fl_Shared_Handler f)
static void remove_handler (Fl_Shared_Handler f)

Protected Member Functions

 Fl_Shared_Image ()
 Fl_Shared_Image (const char *n, Fl_Image *img=0)
virtual ~Fl_Shared_Image ()
void add ()
void update ()

Static Protected Member Functions

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

Protected Attributes

const char * name_
int original_
int refcount_
Fl_Imageimage_
int alloc_image_

Static Protected Attributes

static Fl_Shared_Image ** images_ = 0
static int num_images_ = 0
static int alloc_images_ = 0
static Fl_Shared_Handlerhandlers_ = 0
static int num_handlers_ = 0
static int alloc_handlers_ = 0

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.

Definition at line 49 of file Fl_Shared_Image.H.


Constructor & Destructor Documentation

Fl_Shared_Image::Fl_Shared_Image ( ) [protected]

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.

Definition at line 95 of file Fl_Shared_Image.cxx.

References alloc_image_, image_, name_, original_, and refcount_.

Referenced by copy(), find(), and get().

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.

Definition at line 111 of file Fl_Shared_Image.cxx.

References alloc_image_, image_, name_, original_, refcount_, reload(), and update().

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.

Definition at line 179 of file Fl_Shared_Image.cxx.

References alloc_image_, image_, and name_.


Member Function Documentation

void Fl_Shared_Image::add ( ) [protected]

Definition at line 132 of file Fl_Shared_Image.cxx.

References alloc_images_, compare(), images_, and num_images_.

Referenced by get().

void Fl_Shared_Image::add_handler ( Fl_Shared_Handler  f) [static]

Adds a shared image handler, which is basically a test function for adding new formats

Definition at line 410 of file Fl_Shared_Image.cxx.

References alloc_handlers_, f, handlers_, i, and num_handlers_.

Referenced by fl_register_images().

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.

Definition at line 304 of file Fl_Shared_Image.cxx.

References Fl_Image::color_average(), image_, and update().

int Fl_Shared_Image::compare ( Fl_Shared_Image **  i0,
Fl_Shared_Image **  i1 
) [static, protected]

Definition at line 76 of file Fl_Shared_Image.cxx.

References i.

Referenced by add(), and find().

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.

Definition at line 275 of file Fl_Shared_Image.cxx.

References alloc_image_, Fl_Image::copy(), Fl_Shared_Image(), image_, name_, refcount_, and update().

Referenced by get(), and Fl_File_Chooser::rescan_keep_filename().

Fl_Image* Fl_Shared_Image::copy ( ) [inline]

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.

Definition at line 83 of file Fl_Shared_Image.H.

References copy(), Fl_Image::h(), and Fl_Image::w().

Referenced by copy().

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.

Definition at line 318 of file Fl_Shared_Image.cxx.

References Fl_Image::desaturate(), image_, and update().

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

The draw() methods draw the image. 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.

Definition at line 331 of file Fl_Shared_Image.cxx.

References Fl_Image::draw(), and image_.

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

The draw() methods draw the image. This form specifies the upper-lefthand corner of the image

Reimplemented from Fl_Image.

Definition at line 87 of file Fl_Shared_Image.H.

References draw(), Fl_Image::h(), and Fl_Image::w().

Referenced by draw().

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

Finds a shared image from its named and size specifications

Definition at line 349 of file Fl_Shared_Image.cxx.

References compare(), Fl_Shared_Image(), Fl_Image::h(), images_, key, name_, num_images_, and Fl_Image::w().

Referenced by get().

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

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.

Definition at line 383 of file Fl_Shared_Image.cxx.

References add(), copy(), find(), Fl_Shared_Image(), H, Fl_Image::h(), image_, NULL, and Fl_Image::w().

Referenced by Fluid_Image::Fluid_Image(), Fl_File_Icon::load_image(), and Fl_File_Chooser::rescan_keep_filename().

Fl_Shared_Image ** Fl_Shared_Image::images ( ) [static]

Returns the Fl_Shared_Image* array

Definition at line 62 of file Fl_Shared_Image.cxx.

References images_.

const char* Fl_Shared_Image::name ( ) [inline]

Returns the filename of the shared image

Definition at line 76 of file Fl_Shared_Image.H.

int Fl_Shared_Image::num_images ( ) [static]

Returns the total number of shared images in the array.

Definition at line 66 of file Fl_Shared_Image.cxx.

References num_images_.

int Fl_Shared_Image::refcount ( ) [inline]

Returns the number of references of this shared image. When reference is below 1, the image is deleted.

Definition at line 78 of file Fl_Shared_Image.H.

void Fl_Shared_Image::release ( )

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.

Definition at line 190 of file Fl_Shared_Image.cxx.

References alloc_images_, i, images_, num_images_, and refcount_.

Referenced by Fl_File_Icon::load_image(), Fl_File_Chooser::rescan_keep_filename(), and Fluid_Image::~Fluid_Image().

void Fl_Shared_Image::reload ( )

Reloads the shared image from disk

Definition at line 221 of file Fl_Shared_Image.cxx.

References alloc_image_, Fl_Image::copy(), fl_fopen(), fp, Fl_Image::h(), handlers_, i, image_, name_, NULL, num_handlers_, update(), and Fl_Image::w().

Referenced by Fl_Shared_Image().

void Fl_Shared_Image::remove_handler ( Fl_Shared_Handler  f) [static]

Removes a shared image handler

Definition at line 440 of file Fl_Shared_Image.cxx.

References handlers_, i, and num_handlers_.

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.

Definition at line 341 of file Fl_Shared_Image.cxx.

References image_, and Fl_Image::uncache().

void Fl_Shared_Image::update ( ) [protected]

Member Data Documentation

int Fl_Shared_Image::alloc_handlers_ = 0 [static, protected]

Definition at line 57 of file Fl_Shared_Image.H.

Referenced by add_handler().

Definition at line 63 of file Fl_Shared_Image.H.

Referenced by copy(), Fl_Shared_Image(), reload(), and ~Fl_Shared_Image().

int Fl_Shared_Image::alloc_images_ = 0 [static, protected]

Definition at line 54 of file Fl_Shared_Image.H.

Referenced by add(), and release().

Fl_Shared_Handler * Fl_Shared_Image::handlers_ = 0 [static, protected]

Definition at line 55 of file Fl_Shared_Image.H.

Referenced by add_handler(), reload(), and remove_handler().

Fl_Shared_Image ** Fl_Shared_Image::images_ = 0 [static, protected]

Definition at line 52 of file Fl_Shared_Image.H.

Referenced by add(), find(), images(), and release().

const char* Fl_Shared_Image::name_ [protected]

Definition at line 59 of file Fl_Shared_Image.H.

Referenced by copy(), find(), Fl_Shared_Image(), reload(), and ~Fl_Shared_Image().

int Fl_Shared_Image::num_handlers_ = 0 [static, protected]

Definition at line 56 of file Fl_Shared_Image.H.

Referenced by add_handler(), reload(), and remove_handler().

int Fl_Shared_Image::num_images_ = 0 [static, protected]

Definition at line 53 of file Fl_Shared_Image.H.

Referenced by add(), find(), num_images(), and release().

int Fl_Shared_Image::original_ [protected]

Definition at line 60 of file Fl_Shared_Image.H.

Referenced by Fl_Shared_Image().

int Fl_Shared_Image::refcount_ [protected]

Definition at line 61 of file Fl_Shared_Image.H.

Referenced by copy(), Fl_Shared_Image(), and release().


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