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

Fl_Image Class Reference

Base class for image caching and drawing. More...

#include <Fl_Image.H>

Inheritance diagram for Fl_Image:
[legend]

Public Member Functions

int w () const
 
int h () const
 
int d () const
 
int ld () const
 
int count () const
 
const char *constdata () const
 
int fail ()
 
 Fl_Image (int W, int H, int D)
 
virtual ~Fl_Image ()
 
virtual Fl_Imagecopy (int W, int H)
 
Fl_Imagecopy ()
 
virtual void color_average (Fl_Color c, float i)
 
void inactive ()
 
virtual void desaturate ()
 
virtual void label (Fl_Widget *w)
 
virtual void label (Fl_Menu_Item *m)
 
virtual void draw (int X, int Y, int W, int H, int cx=0, int cy=0)
 
void draw (int X, int Y)
 
virtual void uncache ()
 

Static Public Member Functions

static void RGB_scaling (Fl_RGB_Scaling)
 
static Fl_RGB_Scaling RGB_scaling ()
 

Static Public Attributes

static const int ERR_NO_IMAGE = -1
 
static const int ERR_FILE_ACCESS = -2
 
static const int ERR_FORMAT = -3
 

Protected Member Functions

void w (int W)
 
void h (int H)
 
void d (int D)
 
void ld (int LD)
 
void data (const char *const *p, int c)
 
void draw_empty (int X, int Y)
 

Static Protected Member Functions

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)
 

Private Member Functions

Fl_Imageoperator= (const Fl_Image &)
 
 Fl_Image (const Fl_Image &)
 

Private Attributes

int w_
 
int h_
 
int d_
 
int ld_
 
int count_
 
const char *constdata_
 

Static Private Attributes

static Fl_RGB_Scaling RGB_scaling_ = FL_RGB_SCALING_NEAREST
 

Detailed Description

Base class for image caching and drawing.

Fl_Image is the base class used for caching and drawing all kinds of images in FLTK. This class keeps track of common image data such as the pixels, colormap, width, height, and depth. Virtual methods are used to provide type-specific image handling.

Since the Fl_Image class does not support image drawing by itself, calling the draw() method results in a box with an X in it being drawn instead.

Definition at line 55 of file Fl_Image.H.

Constructor & Destructor Documentation

◆ Fl_Image() [1/2]

Fl_Image::Fl_Image ( const Fl_Image )
private

Referenced by copy().

◆ Fl_Image() [2/2]

Fl_Image::Fl_Image ( int  W,
int  H,
int  D 
)

The constructor creates an empty image with the specified width, height, and depth. The width and height are in pixels. The depth is 0 for bitmaps, 1 for pixmap (colormap) images, and 1 to 4 for color images.

Definition at line 47 of file Fl_Image.cxx.

◆ ~Fl_Image()

Fl_Image::~Fl_Image ( )
virtual

The destructor is a virtual method that frees all memory used by the image.

Definition at line 55 of file Fl_Image.cxx.

Member Function Documentation

◆ color_average()

void Fl_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.

An internal copy is made of the original image before changes are applied, to avoid modifying the original image.

Reimplemented in Fl_RGB_Image, Fl_Shared_Image, Fl_Pixmap, and Fl_Tiled_Image.

Definition at line 106 of file Fl_Image.cxx.

Referenced by Fl_Tiled_Image::color_average(), and Fl_Shared_Image::color_average().

◆ copy() [1/2]

Fl_Image* Fl_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.

Definition at line 150 of file Fl_Image.H.

References copy().

Referenced by copy().

◆ copy() [2/2]

Fl_Image * Fl_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 in Fl_RGB_Image, Fl_Shared_Image, Fl_Pixmap, Fl_Bitmap, and Fl_Tiled_Image.

Definition at line 91 of file Fl_Image.cxx.

References d(), Fl_Image(), and H.

Referenced by Fl_Tree_Prefs::closeicon(), Fl_Tiled_Image::color_average(), Fl_Window::combine_mask(), Fl_Shared_Image::copy(), Fl_Tiled_Image::desaturate(), Fl_Shared_Image::draw(), Fl_Window::draw(), Fl_Tree_Prefs::Fl_Tree_Prefs(), Fl_Tree_Prefs::openicon(), Fl_Shared_Image::reload(), and Fl_Tree_Prefs::usericon().

◆ count()

int Fl_Image::count ( ) const
inline

The count() method returns the number of data values associated with the image. The value will be 0 for images with no associated data, 1 for bitmap and color images, and greater than 2 for pixmap images.

Definition at line 133 of file Fl_Image.H.

Referenced by Fl_Pixmap::delete_data(), Fl_Shared_Image::draw(), Fl_File_Icon::load_image(), Fl_Window::shape(), Fl_Shared_Image::update(), Fl_File_Chooser::update_preview(), and Fluid_Image::write_static().

◆ d() [1/2]

◆ d() [2/2]

◆ data() [1/2]

◆ data() [2/2]

void Fl_Image::data ( const char *const p,
int  c 
)
inlineprotected

◆ desaturate()

void Fl_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.

An internal copy is made of the original image before changes are applied, to avoid modifying the original image.

Reimplemented in Fl_RGB_Image, Fl_Shared_Image, Fl_Pixmap, and Fl_Tiled_Image.

Definition at line 117 of file Fl_Image.cxx.

Referenced by Fl_Tiled_Image::desaturate(), and Fl_Shared_Image::desaturate().

◆ draw() [1/2]

void Fl_Image::draw ( int  X,
int  Y 
)
inline

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

Definition at line 180 of file Fl_Image.H.

References draw(), and Y.

Referenced by draw().

◆ draw() [2/2]

void Fl_Image::draw ( int  X,
int  Y,
int  W,
int  H,
int  cx = 0,
int  cy = 0 
)
virtual

Draws the image with a bounding box. Arguments X,Y,W,H specify a bounding box for the image, with the origin
(upper-left corner) of the image offset by the cx and cy arguments.

In other words: fl_push_clip(X,Y,W,H) is applied, the image is drawn with its upper-left corner at X-cx,Y-cy and its own width and height, fl_pop_clip() is applied.

Reimplemented in Fl_RGB_Image, Fl_Pixmap, Fl_Bitmap, Fl_Shared_Image, and Fl_Tiled_Image.

Definition at line 66 of file Fl_Image.cxx.

References draw_empty().

Referenced by Fl_Tiled_Image::draw(), Fl_Shared_Image::draw(), Fl_Tree_Item::draw(), Fl_Scroll::draw_clip(), Fl_PostScript_Graphics_Driver::draw_scaled(), fl_draw(), Fl_Browser::item_draw(), and labeltype().

◆ draw_empty()

void Fl_Image::draw_empty ( int  X,
int  Y 
)
protected

The protected method draw_empty() draws a box with an X in it. It can be used to draw any image that lacks image data.

Definition at line 75 of file Fl_Image.cxx.

References fl_color(), FL_FOREGROUND_COLOR, fl_line(), fl_rect(), h(), w(), and Y.

Referenced by draw(), Fl_Xlib_Graphics_Driver::draw(), Fl_Pixmap::prepare(), and Fl_Bitmap::start().

◆ fail()

int Fl_Image::fail ( )

Returns a value that is not 0 if there is currently no image available.

Example use:

[..]
Fl_Box box(X,Y,W,H);
Fl_JPEG_Image jpg("/tmp/foo.jpg");
switch ( jpg.fail() ) {
fl_alert("/tmp/foo.jpg: %s", strerror(errno)); // shows actual os error to user
exit(1);
fl_alert("/tmp/foo.jpg: couldn't decode image");
exit(1);
}
box.image(jpg);
[..]
Returns
ERR_NO_IMAGE if no image was found
ERR_FILE_ACCESS if there was a file access related error (errno should be set)
ERR_FORMAT if image decoding failed.

Definition at line 169 of file Fl_Image.cxx.

References d_, ERR_NO_IMAGE, h_, ld_, and w_.

◆ h() [1/2]

◆ h() [2/2]

◆ inactive()

void Fl_Image::inactive ( )
inline

The inactive() method calls color_average(FL_BACKGROUND_COLOR, 0.33f) to produce an image that appears grayed out.

An internal copy is made of the original image before changes are applied, to avoid modifying the original image.

Definition at line 160 of file Fl_Image.H.

References f, and FL_GRAY.

Referenced by Fl_Tree_Prefs::closeicon(), Fl_Tree_Prefs::Fl_Tree_Prefs(), Fl_Tree_Prefs::openicon(), and Fl_Tree_Prefs::usericon().

◆ label() [1/2]

void Fl_Image::label ( Fl_Menu_Item m)
virtual

The label() methods are an obsolete way to set the image attribute of a widget or menu item. Use the image() or deimage() methods of the Fl_Widget and Fl_Menu_Item classes instead.

Reimplemented in Fl_RGB_Image, Fl_Pixmap, and Fl_Bitmap.

Definition at line 138 of file Fl_Image.cxx.

References _FL_IMAGE_LABEL, Fl_Menu_Item::label(), labeltype(), measure(), and Fl::set_labeltype().

◆ label() [2/2]

void Fl_Image::label ( Fl_Widget widget)
virtual

The label() methods are an obsolete way to set the image attribute of a widget or menu item. Use the image() or deimage() methods of the Fl_Widget and Fl_Menu_Item classes instead.

Reimplemented in Fl_RGB_Image, Fl_Pixmap, and Fl_Bitmap.

Definition at line 127 of file Fl_Image.cxx.

References Fl_Widget::image().

Referenced by Fl_Menu_Type::build_menu(), Fl_Input_Choice_Type::build_menu(), and Fl_Menu_Item::image().

◆ labeltype()

void Fl_Image::labeltype ( const Fl_Label lo,
int  lx,
int  ly,
int  lw,
int  lh,
Fl_Align  la 
)
staticprotected

◆ ld() [1/2]

◆ ld() [2/2]

void Fl_Image::ld ( int  LD)
inlineprotected

Sets the current line data size in bytes.

Color images may contain extra data that is included after every line of color image data and is normally not present.

If LD is zero, then line data size is assumed to be w() * d() bytes.

If LD is non-zero, then it must be positive and larger than w() * d() to account for the extra data per line.

Definition at line 96 of file Fl_Image.H.

Referenced by alpha_blend(), Fl_PostScript_Graphics_Driver::draw(), Fl_Xlib_Graphics_Driver::draw(), icons_to_property(), image_to_icon(), Fl_File_Icon::load_image(), Fl_Gl_Device_Plugin::print(), write_image_inside(), and Fluid_Image::write_static().

◆ measure()

void Fl_Image::measure ( const Fl_Label lo,
int &  lw,
int &  lh 
)
staticprotected

◆ operator=()

Fl_Image& Fl_Image::operator= ( const Fl_Image )
private

◆ RGB_scaling() [1/2]

Fl_RGB_Scaling Fl_Image::RGB_scaling ( )
static

Returns the currently used RGB image scaling method.

Definition at line 226 of file Fl_Image.cxx.

References RGB_scaling_.

Referenced by Fl_RGB_Image::copy(), Fl_Shared_Image::draw(), and Fl_Paged_Device::draw_decorated_window().

◆ RGB_scaling() [2/2]

void Fl_Image::RGB_scaling ( Fl_RGB_Scaling  method)
static

Sets the RGB image scaling method used for copy(int, int). Applies to all RGB images, defaults to FL_RGB_SCALING_NEAREST.

Definition at line 221 of file Fl_Image.cxx.

References RGB_scaling_.

◆ uncache()

void Fl_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 in Fl_RGB_Image, Fl_Shared_Image, Fl_Pixmap, and Fl_Bitmap.

Definition at line 63 of file Fl_Image.cxx.

Referenced by Fl_Shared_Image::uncache().

◆ w() [1/2]

◆ w() [2/2]

Member Data Documentation

◆ count_

int Fl_Image::count_
private

Definition at line 63 of file Fl_Image.H.

◆ d_

int Fl_Image::d_
private

Definition at line 63 of file Fl_Image.H.

Referenced by fail().

◆ data_

const char* const * Fl_Image::data_
private

Definition at line 64 of file Fl_Image.H.

◆ ERR_FILE_ACCESS

◆ ERR_FORMAT

◆ ERR_NO_IMAGE

const int Fl_Image::ERR_NO_IMAGE = -1
static

Definition at line 58 of file Fl_Image.H.

Referenced by fail().

◆ h_

int Fl_Image::h_
private

Definition at line 63 of file Fl_Image.H.

Referenced by fail().

◆ ld_

int Fl_Image::ld_
private

Definition at line 63 of file Fl_Image.H.

Referenced by fail().

◆ RGB_scaling_

Fl_RGB_Scaling Fl_Image::RGB_scaling_ = FL_RGB_SCALING_NEAREST
staticprivate

Definition at line 65 of file Fl_Image.H.

Referenced by RGB_scaling().

◆ w_

int Fl_Image::w_
private

Definition at line 63 of file Fl_Image.H.

Referenced by fail().


The documentation for this class was generated from the following files:
box
Definition: jquant2.c:259
H
static int H
Definition: Fl_Tooltip.cxx:76
Fl_JPEG_Image
Definition: Fl_JPEG_Image.H:32
Fl_Image::ERR_FORMAT
static const int ERR_FORMAT
Definition: Fl_Image.H:60
Fl_Box
Definition: Fl_Box.H:34
Y
static int Y
Definition: Fl_Tooltip.cxx:76
Fl_Image::ERR_NO_IMAGE
static const int ERR_NO_IMAGE
Definition: Fl_Image.H:58
Fl_Image::ERR_FILE_ACCESS
static const int ERR_FILE_ACCESS
Definition: Fl_Image.H:59
fl_alert
void fl_alert(const char *,...)
Definition: fl_ask.cxx:361