fltk::xpmImage Class Reference

Inherits fltk::Image.

List of all members.

Public Member Functions

bool fetch ()

Static Public Member Functions

static bool fetch (Image &, const char *const *data)
 For xpmFileImage to reuse fetch() code.

Detailed Description

Draws inline XPM data. This is a text-based 256-color image format designed for X11 and still very useful for making small icons, since the data can be easily inserted into your source code:

#include "image_name.xpm"
static xpmImage image_name(image_name_xpm);

FLTK recognizes a few extensions to the xpm color map: Setting the number of colors negative means the second line in the array is a "compressed" colormap, which is 4 bytes per color of character,r,g,b. If all colors are grays and there is no transparent index, it instead makes a MASK image, where black draws the current color and white is transparent, and all other grays are partially transparent. This allows you to put antialiased glyphs into images.


Member Function Documentation

bool xpmImage::fetch ( ) [virtual]

This is called by the draw() functions once after the Image is created or after refetch() has been called. This allows subclasses to defer reading files and calling setpixels() calls until the first draw() or measure(). This should return true if successful, false on any error (though fltk does not do anything useful with errors).

The base class does nothing and returns true, thus leaving the image unchanged.

Sample implementation:

  bool MyImage::fetch() {
    setsize(get_width(file), get_height(file));
    setpixeltype(my_pixeltype);
    for (int y=0; y<height(); y++) {
      uchar* buffer = linebuffer(y);
      get_line_of_pixels(file, buffer, y);
      setpixels(buffer, y);
    }
    return true;
  }

Reimplemented from fltk::Image.


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