FLTK 1.4.0
No Matches
Fl_Shared_Image.H File Reference

Fl_Shared_Image class. More...

#include "Fl_Image.H"

Go to the source code of this file.


class  Fl_Shared_Image
 This class supports caching, loading, and drawing of image files. More...


typedef Fl_Image *(* Fl_Shared_Handler) (const char *name, uchar *header, int headerlen)
 Test function (typedef) for adding new shared image formats.


void fl_register_images ()
 Register the known image formats.

Detailed Description

Typedef Documentation

◆ Fl_Shared_Handler

typedef Fl_Image *(* Fl_Shared_Handler) (const char *name, uchar *header, int headerlen)

Test function (typedef) for adding new shared image formats.

This defines the function type you can use to add a handler for unknown image formats that can be opened and loaded as an Fl_Shared_Image.

fl_register_images() adds all image formats known to FLTK. Call Fl_Shared_Image::add_handler() to add your own check function to the list of known image formats.

Your function will be passed the filename (name), some header bytes already read from the image file and the size headerlen of the data read. The max value of size is implementation dependent. If your handler function needs to check more bytes you must open the image file yourself.

The provided buffer header must not be overwritten.

If your handler function can identify the file type you must open the file and return a valid Fl_Image or derived type, otherwise you must return NULL. Example:

static Fl_Image *check_my_image(const char *name,
uchar *header,
int headerlen) {
// (test image type using header and headerlen)
if (known) {
// (load image data from file \p name)
return new Fl_RGB_Image(data, ...);
} else
return 0;
// add your handler:
Base class for image caching, scaling and drawing.
Definition Fl_Image.H:60
The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of colo...
Definition Fl_Image.H:339
static void add_handler(Fl_Shared_Handler f)
Adds a shared image handler, which is basically a test function for adding new image formats.
Definition Fl_Shared_Image.cxx:652
unsigned char uchar
unsigned char
Definition fl_types.h:30
[in]namefilename to be checked and opened if applicable
[in]headerportion of the file that has already been read
[in]headerlenlength of provided header data
valid Fl_Image or NULL.
See also

Function Documentation

◆ fl_register_images()

void fl_register_images ( )

Register the known image formats.

This function is provided in the fltk_images library and registers all of the "extra" image file formats known to FLTK that are not part of the core FLTK library.

You may add your own image formats with Fl_Shared_Image::add_handler().