Inherits fltk::SharedImage.
Public Member Functions | |
bool | fetch () |
Static Public Member Functions | |
static bool | test (const uchar *datas, unsigned size=0) |
Image type that reads a .xpm (X Pixmap) file in from disk.
The normal use of a .xpm file is to #include it into your source code. In that case you want to use an fltk::xpmImage object.
bool xpmFileImage::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; }
Implements fltk::SharedImage.
bool xpmFileImage::test | ( | const uchar * | datas, |
unsigned | size = 0 |
||
) | [static] |
Test a block of data read from the start of the file to see if it looks like the start of a .xpm file. This returns true if the data contains "/\* XPM".