FLTK 1.4.4: Fl_Shared_Image.H File Reference

FLTK 1.4.4

Loading...
Searching...
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.

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

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

## Functions
void | fl_register_images ()
| Register the known image formats.

## Detailed Description

Fl_Shared_Image class.

## 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:
Fl_Shared_Image::add_handler(check_my_image);
Fl_Image
Base class for image caching, scaling and drawing.
Definition Fl_Image.H:60
Fl_RGB_Image
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
Fl_Shared_Image::add_handler
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
uchar
unsigned char uchar
unsigned char
Definition fl_types.h:30

Parameters

  [in] | name | filename to be checked and opened if applicable
  [in] | header | portion of the file that has already been read
  [in] | headerlen | length of provided `header` data

Returns
  valid Fl_Image or `NULL`.

See also
  Fl_Shared_Image::add_handler()

## Function Documentation

## ◆ fl_register_images()

void fl_register_images | ( |  | ) |
| extern

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().