FLTK 1.3.3

- Main Page
- Related Pages
- Modules
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
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:

## 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. More...
virtual Fl_Image * | copy (int W, int H)
| The copy() method creates a copy of the specified image. More...
Fl_Image * | copy ()
virtual void | desaturate ()
| The desaturate() method converts an image to grayscale. More...
virtual void | draw (int X, int Y, int W, int H, int cx, int cy)
| Draws the image with a bounding box. More...
void | draw (int X, int Y)
const char * | name ()
| Returns the filename of the shared image.
int | refcount ()
| Returns the number of references of this shared image. More...
void | release ()
| Releases and possibly destroys (if refcount <=0) a shared image. More...
void | reload ()
| Reloads the shared image from disk.
virtual void | uncache ()
| If the image has been cached for display, delete the cache data. More...
Public Member Functions inherited from Fl_Image
Fl_Image * | copy ()
| The copy() method creates a copy of the specified image. More...
int | count () const
| The count() method returns the number of data values associated with the image. More...
int | d () const
| Returns the current image depth. More...
const char *const * | data () const
| Returns a pointer to the current image data array. More...
void | draw (int X, int Y)
| Draws the image. More...
| Fl_Image (int W, int H, int D)
| The constructor creates an empty image with the specified width, height, and depth. More...
int | h () const
| Returns the current image height in pixels.
void | inactive ()
| The inactive() method calls color_average(FL_BACKGROUND_COLOR, 0.33f) to produce an image that appears grayed out. More...
virtual void | label (Fl_Widget *w)
| The label() methods are an obsolete way to set the image attribute of a widget or menu item. More...
virtual void | label (Fl_Menu_Item *m)
| The label() methods are an obsolete way to set the image attribute of a widget or menu item. More...
int | ld () const
| Returns the current line data size in bytes. More...
int | w () const
| Returns the current image width in pixels.
virtual | ~Fl_Image ()
| The destructor is a virtual method that frees all memory used by the image.

## 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_Image * | find (const char *n, int W=0, int H=0)
| Finds a shared image from its named and size specifications.
static Fl_Shared_Image * | get (const char *n, int W=0, int H=0)
| Find or load an image that can be shared by multiple widgets. More...
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. More...
static void | remove_handler (Fl_Shared_Handler f)
| Removes a shared image handler.
Static Public Member Functions inherited from Fl_Image
static void | RGB_scaling (Fl_RGB_Scaling)
| Sets the RGB image scaling method used for copy(int, int). More...
static Fl_RGB_Scaling | RGB_scaling ()
| Returns the currently used RGB image scaling method. More...

## Protected Member Functions
void | add ()
| Fl_Shared_Image ()
| Creates an empty shared image. More...
| Fl_Shared_Image (const char *n, Fl_Image *img=0)
| Creates a shared image from its filename and its corresponding Fl_Image* img. More...
void | update ()
virtual | ~Fl_Shared_Image ()
| The destructor free all memory and server resources that are used by the image. More...
Protected Member Functions inherited from Fl_Image
void | d (int D)
| Sets the current image depth.
void | data (const char *const *p, int c)
| Sets the current array pointer and count of pointers in the array.
void | draw_empty (int X, int Y)
| The protected method draw_empty() draws a box with an X in it. More...
void | h (int H)
| Sets the current image height in pixels.
void | ld (int LD)
| Sets the current line data size in bytes.
void | w (int W)
| Sets the current image width in pixels.

## Static Protected Member Functions
static int | compare (Fl_Shared_Image **i0, Fl_Shared_Image **i1)
Static Protected Member Functions inherited from Fl_Image
static void | labeltype (const Fl_Label *lo, int lx, int ly, int lw, int lh, Fl_Align la)
static void | measure (const Fl_Label *lo, int &lw, int &lh)

## Protected Attributes
int | alloc_image_
Fl_Image * | image_
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

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.

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.

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.

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

  n | name of the image
  W,H | desired 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.

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.

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:

- Fl_Shared_Image.H
- Fl_Shared_Image.cxx

- © 1998-2014 by Bill Spitzak and others.