fltk.core.images

FLTK Images Library Bindings

This package provides low-level D bindings for the FLTK images library (libfltk_images), which adds support for loading various image formats.

Supported image formats:

  • BMP (Windows Bitmap)
  • GIF (Graphics Interchange Format)
  • JPEG (Joint Photographic Experts Group)
  • PNG (Portable Network Graphics)
  • PNM/PPM/PGM (Portable Anymap)
  • XBM (X BitMap)
  • XPM (X PixMap)

Memory Management:

  • Images created with *_new() functions must be destroyed with fltk_image_delete()
  • Shared images use reference counting via Fl_Shared_Image

Example:

import fltk.core.images;

void main() {
   // Load a PNG image
   auto img = fltk_png_image_new("photo.png");
   if (img !is null) {
      auto w = fltk_image_w(fltk_png_image_as_image(img));
      auto h = fltk_image_h(fltk_png_image_as_image(img));
      writefln("Image size: %dx%d", w, h);
      fltk_png_image_delete(img);
   }
}

Authors

Dejan Lekić

License

BSD-3-Clause

Types 27

Opaque handle for Fl_Image base class.

This is the base type for all image handles.

Fields
private void * ptr

Alias for image handle

Opaque handle for Fl_RGB_Image.

RGB images store pixel data in RGB or RGBA format.

Fields
private void * ptr

Alias for RGB image handle

Opaque handle for Fl_Bitmap.

Bitmaps are monochrome (1-bit) images.

Fields
private void * ptr

Alias for bitmap handle

Opaque handle for Fl_Pixmap.

Pixmaps store images in XPM format.

Fields
private void * ptr

Alias for pixmap handle

Opaque handle for Fl_Shared_Image.

Shared images are reference-counted and cached.

Fields
private void * ptr

Alias for shared image handle

Opaque handle for Fl_BMP_Image.

Fields
private void * ptr

Alias for BMP image handle

Opaque handle for Fl_GIF_Image.

Fields
private void * ptr

Alias for GIF image handle

Opaque handle for Fl_JPEG_Image.

Fields
private void * ptr

Alias for JPEG image handle

Opaque handle for Fl_PNG_Image.

Fields
private void * ptr

Alias for PNG image handle

Opaque handle for Fl_PNM_Image.

Fields
private void * ptr

Alias for PNM image handle

Opaque handle for Fl_XBM_Image.

Fields
private void * ptr

Alias for XBM image handle

Opaque handle for Fl_XPM_Image.

Fields
private void * ptr

Alias for XPM image handle

Opaque handle for Fl_Tiled_Image.

Fields
private void * ptr

Alias for tiled image handle

Image loading error codes.

These values indicate the result of image loading operations.

OK = 0Image loaded successfully
FILE_NOT_FOUND = 1File not found or cannot be opened
INVALID_DATA = 2Invalid or corrupt image data
UNSUPPORTED_FORMAT = 3Unsupported image format
OUT_OF_MEMORY = 4Memory allocation failed

Functions 63

fnbool isValid(FltkImage image) @safe nothrow @nogcChecks if an image handle is valid (non-null).
fnbool isValid(FltkPngImage image) @safe nothrow @nogcChecks if a PNG image handle is valid (non-null).
fnbool isValid(FltkJpegImage image) @safe nothrow @nogcChecks if a JPEG image handle is valid (non-null).
fnbool isValid(FltkBmpImage image) @safe nothrow @nogcChecks if a BMP image handle is valid (non-null).
fnbool isValid(FltkGifImage image) @safe nothrow @nogcChecks if a GIF image handle is valid (non-null).
fnbool isValid(FltkSharedImage image) @safe nothrow @nogcChecks if a shared image handle is valid (non-null).
fnint fltk_image_w(FltkImage image)Gets the image width.
fnint fltk_image_h(FltkImage image)Gets the image height.
fnint fltk_image_d(FltkImage image)Gets the image depth (bytes per pixel).
fnint fltk_image_ld(FltkImage image)Gets the image line data size.
fnint fltk_image_count(FltkImage image)Gets the image data count.
fnconst(ubyte *) * fltk_image_data(FltkImage image)Gets a pointer to the image pixel data.
fnFltkImage fltk_image_copy(FltkImage image, int w, int h)Creates a copy of the image, optionally scaled.
fnvoid fltk_image_color_average(FltkImage image, uint color, float blend)Applies a color average to the image.
fnvoid fltk_image_inactive(FltkImage image)Creates an inactive (grayed) version of the image.
fnvoid fltk_image_desaturate(FltkImage image)Desaturates the image in place.
fnvoid fltk_image_delete(FltkImage image)Deletes an image.
fnFltkRgbImage fltk_rgb_image_new(const(ubyte) * data, int w, int h, int d, int ld)Creates a new RGB image from pixel data.
fnvoid fltk_rgb_image_delete(FltkRgbImage image)Deletes an RGB image.
fnFltkImage fltk_rgb_image_as_image(FltkRgbImage image)Casts an RGB image to base image.
fnFltkPngImage fltk_png_image_new(const(char) * filename)Creates a new PNG image from a file.
fnFltkPngImage fltk_png_image_new_data(const(ubyte) * data, int len)Creates a new PNG image from memory data.
fnvoid fltk_png_image_delete(FltkPngImage image)Deletes a PNG image.
fnFltkImage fltk_png_image_as_image(FltkPngImage image)Casts a PNG image to base image.
fnint fltk_png_image_fail(FltkPngImage image)Gets the error status of a PNG image load.
fnFltkJpegImage fltk_jpeg_image_new(const(char) * filename)Creates a new JPEG image from a file.
fnFltkJpegImage fltk_jpeg_image_new_data(const(ubyte) * data, int len)Creates a new JPEG image from memory data.
fnvoid fltk_jpeg_image_delete(FltkJpegImage image)Deletes a JPEG image.
fnFltkImage fltk_jpeg_image_as_image(FltkJpegImage image)Casts a JPEG image to base image.
fnint fltk_jpeg_image_fail(FltkJpegImage image)Gets the error status of a JPEG image load.
fnFltkBmpImage fltk_bmp_image_new(const(char) * filename)Creates a new BMP image from a file.
fnvoid fltk_bmp_image_delete(FltkBmpImage image)Deletes a BMP image.
fnFltkImage fltk_bmp_image_as_image(FltkBmpImage image)Casts a BMP image to base image.
fnint fltk_bmp_image_fail(FltkBmpImage image)Gets the error status of a BMP image load.
fnFltkPnmImage fltk_pnm_image_new(const(char) * filename)Creates a new PNM image from a file.
fnvoid fltk_pnm_image_delete(FltkPnmImage image)Deletes a PNM image.
fnFltkImage fltk_pnm_image_as_image(FltkPnmImage image)Casts a PNM image to base image.
fnint fltk_pnm_image_fail(FltkPnmImage image)Gets the error status of a PNM image load.
fnFltkGifImage fltk_gif_image_new(const(char) * filename)Creates a new GIF image from a file.
fnvoid fltk_gif_image_delete(FltkGifImage image)Deletes a GIF image.
fnFltkImage fltk_gif_image_as_image(FltkGifImage image)Casts a GIF image to base image.
fnint fltk_gif_image_fail(FltkGifImage image)Gets the error status of a GIF image load.
fnFltkBitmap fltk_bitmap_new(const(ubyte) * bits, int w, int h)Creates a new bitmap from XBM data.
fnvoid fltk_bitmap_delete(FltkBitmap bm)Deletes a bitmap.
fnFltkImage fltk_bitmap_as_image(FltkBitmap bm)Casts a bitmap to base image.
fnFltkPixmap fltk_pixmap_new(const(char *) * data)Creates a new pixmap from XPM data.
fnvoid fltk_pixmap_delete(FltkPixmap pm)Deletes a pixmap.
fnFltkImage fltk_pixmap_as_image(FltkPixmap pm)Casts a pixmap to base image.
fnFltkXbmImage fltk_xbm_image_new(const(char) * filename)Creates an XBM image from a file.
fnvoid fltk_xbm_image_delete(FltkXbmImage img)Deletes an XBM image.
fnFltkImage fltk_xbm_image_as_image(FltkXbmImage img)Casts an XBM image to base image.
fnint fltk_xbm_image_fail(FltkXbmImage img)Gets the error status of an XBM image load.
fnFltkXpmImage fltk_xpm_image_new(const(char) * filename)Creates an XPM image from a file.
fnvoid fltk_xpm_image_delete(FltkXpmImage img)Deletes an XPM image.
fnFltkImage fltk_xpm_image_as_image(FltkXpmImage img)Casts an XPM image to base image.
fnint fltk_xpm_image_fail(FltkXpmImage img)Gets the error status of an XPM image load.
fnFltkTiledImage fltk_tiled_image_new(FltkImage image, int w, int h)Creates a new tiled image from a source image.
fnvoid fltk_tiled_image_delete(FltkTiledImage ti)Deletes a tiled image.
fnFltkImage fltk_tiled_image_as_image(FltkTiledImage ti)Casts a tiled image to base image.
fnFltkSharedImage fltk_shared_image_get(const(char) * filename)Gets a shared image from file (loads if not cached).
fnFltkSharedImage fltk_shared_image_find(const(char) * filename)Finds a shared image in the cache.
fnvoid fltk_shared_image_release(FltkSharedImage image)Releases a reference to a shared image.
fnFltkImage fltk_shared_image_as_image(FltkSharedImage image)Casts a shared image to base image.