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.
![]() ![]() |
Base class for image caching and drawing. More...
#include <Fl_Image.H>
Public Member Functions | |
int | w () const |
int | h () const |
int | d () const |
int | ld () const |
int | count () const |
const char *const * | data () const |
int | fail () |
Fl_Image (int W, int H, int D) | |
virtual | ~Fl_Image () |
virtual Fl_Image * | copy (int W, int H) |
Fl_Image * | copy () |
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_Image & | operator= (const Fl_Image &) |
Fl_Image (const Fl_Image &) | |
Private Attributes | |
int | w_ |
int | h_ |
int | d_ |
int | ld_ |
int | count_ |
const char *const * | data_ |
Static Private Attributes | |
static Fl_RGB_Scaling | RGB_scaling_ = FL_RGB_SCALING_NEAREST |
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.
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.
|
virtual |
The destructor is a virtual method that frees all memory used by the image.
Definition at line 55 of file Fl_Image.cxx.
|
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().
|
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().
|
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().
|
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().
|
inline |
Returns the current image depth. The return value will be 0 for bitmaps, 1 for pixmaps, and 1 to 4 for color images.
Definition at line 121 of file Fl_Image.H.
Referenced by Fl_RGB_Image::color_average(), copy(), Fl_RGB_Image::copy(), Fl_RGB_Image::desaturate(), Fl_Shared_Image::draw(), Fl_BMP_Image::Fl_BMP_Image(), Fl_GIF_Image::Fl_GIF_Image(), Fl_JPEG_Image::Fl_JPEG_Image(), fl_mult_matrix(), Fl_PNM_Image::Fl_PNM_Image(), Fl_RGB_Image::Fl_RGB_Image(), fl_rotate(), Fl_Graphics_Driver::font_descriptor(), Fl_PNG_Image::load_png_(), and Fl_Shared_Image::update().
|
inlineprotected |
Sets the current image depth.
Definition at line 84 of file Fl_Image.H.
Referenced by alpha_blend(), Fl_PostScript_Graphics_Driver::draw(), Fl_Xlib_Graphics_Driver::draw(), fl_handle(), icons_to_property(), image_to_icon(), Fl_File_Icon::load_image(), Fl_Gl_Device_Plugin::print(), Fl_Window::shape(), Fl_Window::shape_alpha_(), Fl_Shared_Image::update(), Fl_File_Chooser::update_preview(), write_image_inside(), and Fluid_Image::write_static().
Returns a pointer to the current image data array. Use the count() method to find the size of the data array.
Definition at line 138 of file Fl_Image.H.
Referenced by Fl_Pixmap::color_average(), Fl_Pixmap::copy(), Fl_Pixmap::copy_data(), Fl_Pixmap::delete_data(), Fl_Pixmap::desaturate(), Fl_Bitmap::Fl_Bitmap(), fl_draw_image(), fl_draw_image_mono(), Fl_GIF_Image::Fl_GIF_Image(), Fl_JPEG_Image::Fl_JPEG_Image(), Fl_RGB_Image::Fl_RGB_Image(), Fl_XPM_Image::Fl_XPM_Image(), Fl_Pixmap::measure(), Fl_Pixmap::prepare(), Fl_Pixmap::set_data(), and Fl_Shared_Image::update().
Sets the current array pointer and count of pointers in the array.
Definition at line 100 of file Fl_Image.H.
References p.
Referenced by Fl_Window::combine_mask(), Fl_PostScript_Graphics_Driver::draw(), fl_handle(), Fl_RGB_Image::Fl_RGB_Image(), icons_to_property(), image_to_icon(), Fl_File_Icon::load_image(), Fl_Window::shape_alpha_(), start(), Fl_Shared_Image::update(), and Fluid_Image::write_static().
|
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().
|
inline |
Draws the image. This form specifies the upper-lefthand corner of the image.
Definition at line 180 of file Fl_Image.H.
Referenced by draw().
|
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().
|
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().
int Fl_Image::fail | ( | ) |
Returns a value that is not 0 if there is currently no image available.
Example use:
Definition at line 169 of file Fl_Image.cxx.
References d_, ERR_NO_IMAGE, h_, ld_, and w_.
|
inline |
Returns the current image height in pixels.
Definition at line 115 of file Fl_Image.H.
Referenced by Fl_RGB_Image::color_average(), Fl_Tiled_Image::copy(), Fl_Bitmap::copy(), Fl_Pixmap::copy(), Fl_Shared_Image::copy(), Fl_RGB_Image::copy(), Fl_Pixmap::copy_data(), Fl_RGB_Image::desaturate(), Fl_Tiled_Image::draw(), Fl_Bitmap::draw(), Fl_Pixmap::draw(), Fl_Shared_Image::draw(), Fl_RGB_Image::draw(), draw_empty(), fl_arc(), Fl_BMP_Image::Fl_BMP_Image(), fl_clip_box(), Fl_GIF_Image::Fl_GIF_Image(), Fl_JPEG_Image::Fl_JPEG_Image(), fl_not_clipped(), fl_pie(), Fl_PNM_Image::Fl_PNM_Image(), fl_push_clip(), fl_rect(), fl_rectf(), Fl_RGB_Image::Fl_RGB_Image(), fl_text_extents(), Fl_XBM_Image::Fl_XBM_Image(), Fl_PNG_Image::load_png_(), Fl_Pixmap::measure(), Fl_Pixmap::prepare(), Fl_Shared_Image::reload(), Fl_Shared_Image::scale(), Fl_Bitmap::start(), and Fl_Shared_Image::update().
|
inlineprotected |
Sets the current image height in pixels.
Definition at line 80 of file Fl_Image.H.
References H.
Referenced by Fl_Tree_Item::calc_item_height(), Fl_Window::combine_mask(), Fl_Tiled_Image::draw(), Fl_Shared_Image::draw(), Fl_Tree_Item::draw(), Fl_PostScript_Graphics_Driver::draw(), Fl_Help_View::draw(), Fl_Xlib_Graphics_Driver::draw(), Fl_Widget::draw_backdrop(), Fl_PostScript_Graphics_Driver::draw_scaled(), Fluid_Image::find(), fl_draw(), fl_handle(), fl_normal_measure(), Fl_RGB_Image::Fl_RGB_Image(), Fl_Help_View::format(), Fl_Help_View::format_table(), Fl_Shared_Image::get(), Fl_Browser::icon(), icons_to_property(), image_to_icon(), Fl_Browser::item_height(), labeltype(), Fl_File_Icon::load_image(), measure(), Fl_Gl_Device_Plugin::print(), Fl_Shared_Image::reload(), Fl_Shared_Image::scale(), Fl_Window::shape_alpha_(), traverse_to_gl_subwindows(), Fl_Shared_Image::update(), Fl_File_Chooser::update_preview(), write_image_inside(), and Fluid_Image::write_static().
|
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.
Referenced by Fl_Tree_Prefs::closeicon(), Fl_Tree_Prefs::Fl_Tree_Prefs(), Fl_Tree_Prefs::openicon(), and Fl_Tree_Prefs::usericon().
|
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().
|
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().
|
staticprotected |
Definition at line 182 of file Fl_Image.cxx.
References Fl_Label::color, draw(), FL_ALIGN_BOTTOM, FL_ALIGN_LEFT, FL_ALIGN_RIGHT, FL_ALIGN_TOP, fl_color(), h(), Fl_Label::value, and w().
Referenced by Fl_Bitmap::label(), Fl_Pixmap::label(), label(), and Fl_RGB_Image::label().
|
inline |
Returns the current line data size in bytes.
Definition at line 126 of file Fl_Image.H.
Referenced by Fl_RGB_Image::color_average(), Fl_RGB_Image::copy(), Fl_RGB_Image::desaturate(), Fl_BMP_Image::Fl_BMP_Image(), Fl_GIF_Image::Fl_GIF_Image(), Fl_JPEG_Image::Fl_JPEG_Image(), Fl_PNM_Image::Fl_PNM_Image(), Fl_RGB_Image::Fl_RGB_Image(), and Fl_PNG_Image::load_png_().
|
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().
Definition at line 207 of file Fl_Image.cxx.
References h(), Fl_Label::value, and w().
Referenced by Fl_Pixmap::Fl_Pixmap(), Fl_Bitmap::label(), Fl_Pixmap::label(), label(), and Fl_RGB_Image::label().
|
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().
|
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_.
|
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().
|
inline |
Returns the current image width in pixels.
Definition at line 111 of file Fl_Image.H.
Referenced by Fl_RGB_Image::color_average(), Fl_Tiled_Image::copy(), Fl_Bitmap::copy(), Fl_Pixmap::copy(), Fl_Shared_Image::copy(), Fl_RGB_Image::copy(), Fl_Pixmap::copy_data(), Fl_RGB_Image::desaturate(), Fl_Tiled_Image::draw(), Fl_Bitmap::draw(), Fl_Pixmap::draw(), Fl_Shared_Image::draw(), Fl_RGB_Image::draw(), draw_empty(), fl_arc(), Fl_BMP_Image::Fl_BMP_Image(), fl_clip_box(), Fl_GIF_Image::Fl_GIF_Image(), Fl_JPEG_Image::Fl_JPEG_Image(), fl_not_clipped(), fl_pie(), Fl_PNM_Image::Fl_PNM_Image(), fl_push_clip(), fl_rect(), fl_rectf(), Fl_RGB_Image::Fl_RGB_Image(), fl_text_extents(), Fl_XBM_Image::Fl_XBM_Image(), Fl_PNG_Image::load_png_(), Fl_Pixmap::measure(), Fl_Pixmap::prepare(), Fl_Shared_Image::reload(), Fl_Shared_Image::scale(), Fl_Bitmap::start(), and Fl_Shared_Image::update().
|
inlineprotected |
Sets the current image width in pixels.
Definition at line 76 of file Fl_Image.H.
Referenced by alpha_blend(), Fl_Window::combine_mask(), Fl_Tiled_Image::draw(), Fl_Shared_Image::draw(), Fl_Tree_Item::draw(), Fl_PostScript_Graphics_Driver::draw(), Fl_Help_View::draw(), Fl_Xlib_Graphics_Driver::draw(), Fl_Widget::draw_backdrop(), Fl_PostScript_Graphics_Driver::draw_scaled(), Fl_Tree::draw_tree(), Fluid_Image::find(), find_best_icon(), fl_draw(), fl_handle(), fl_normal_measure(), Fl_RGB_Image::Fl_RGB_Image(), Fl_Help_View::format(), Fl_Help_View::format_table(), Fl_Shared_Image::get(), icons_to_property(), image_to_icon(), Fl_Browser::item_draw(), Fl_Browser::item_width(), labeltype(), Fl_File_Icon::load_image(), measure(), Fl_Gl_Device_Plugin::print(), Fl_Shared_Image::reload(), Fl_Shared_Image::scale(), Fl_Window::shape_alpha_(), traverse_to_gl_subwindows(), Fl_Shared_Image::update(), Fl_File_Chooser::update_preview(), write_image_inside(), and Fluid_Image::write_static().
|
private |
Definition at line 63 of file Fl_Image.H.
|
private |
Definition at line 63 of file Fl_Image.H.
Referenced by fail().
Definition at line 64 of file Fl_Image.H.
|
static |
Definition at line 59 of file Fl_Image.H.
Referenced by Fl_BMP_Image::Fl_BMP_Image(), Fl_GIF_Image::Fl_GIF_Image(), Fl_JPEG_Image::Fl_JPEG_Image(), Fl_PNM_Image::Fl_PNM_Image(), and Fl_PNG_Image::load_png_().
|
static |
Definition at line 60 of file Fl_Image.H.
Referenced by Fl_BMP_Image::Fl_BMP_Image(), Fl_GIF_Image::Fl_GIF_Image(), Fl_JPEG_Image::Fl_JPEG_Image(), Fl_PNM_Image::Fl_PNM_Image(), and Fl_PNG_Image::load_png_().
|
static |
Definition at line 58 of file Fl_Image.H.
Referenced by fail().
|
private |
Definition at line 63 of file Fl_Image.H.
Referenced by fail().
|
private |
Definition at line 63 of file Fl_Image.H.
Referenced by fail().
|
staticprivate |
Definition at line 65 of file Fl_Image.H.
Referenced by RGB_scaling().
|
private |
Definition at line 63 of file Fl_Image.H.
Referenced by fail().