fltk.images.loaders

FLTK Image Format Loaders

This module provides classes for loading images from various file formats:

  • PngImage: PNG format (Portable Network Graphics)
  • JpegImage: JPEG format (Joint Photographic Experts Group)
  • BmpImage: BMP format (Windows Bitmap)
  • GifImage: GIF format (Graphics Interchange Format)

    Authors

    Dejan Lekić

    License

    BSD-3-Clause

Types 5

PNG image loaded from file or memory.

PNG supports lossless compression, transparency (alpha channel), and various color depths.

Example:

auto img = new PngImage("photo.png");
if (img.isValid) {
   writefln("Loaded %dx%d PNG", img.width, img.height);
}

Fields
FltkPngImage _pngHandle
Methods
FltkPngImage pngHandle() @safe nothrow @nogcReturns the underlying PNG image handle.
bool isValid() const @trusted nothrow @nogcChecks if the PNG image loaded successfully.
int fail() const nothrow @nogcGets the error status of the image load.
Constructors
this(string filename)Loads a PNG image from a file.
this(const(ubyte)[] data)Loads a PNG image from memory data.
Destructors
~thisDestroys the PNG image.

JPEG image loaded from file or memory.

JPEG uses lossy compression and is ideal for photographs.

Note

JPEG does not support transparency.

Example:

auto img = new JpegImage("photo.jpg");
if (img.isValid) {
   writefln("Loaded %dx%d JPEG", img.width, img.height);
}

Fields
FltkJpegImage _jpegHandle
Methods
FltkJpegImage jpegHandle() @safe nothrow @nogcReturns the underlying JPEG image handle.
bool isValid() const @trusted nothrow @nogcChecks if the JPEG image loaded successfully.
int fail() const nothrow @nogcGets the error status of the image load.
Constructors
this(string filename)Loads a JPEG image from a file.
this(const(ubyte)[] data)Loads a JPEG image from memory data.
Destructors
~thisDestroys the JPEG image.

BMP image loaded from file.

BMP is Windows Bitmap format, typically uncompressed.

Example:

auto img = new BmpImage("image.bmp");
if (img.isValid) {
   writefln("Loaded %dx%d BMP", img.width, img.height);
}

Fields
FltkBmpImage _bmpHandle
Methods
FltkBmpImage bmpHandle() @safe nothrow @nogcReturns the underlying BMP image handle.
bool isValid() const @trusted nothrow @nogcChecks if the BMP image loaded successfully.
int fail() const nothrow @nogcGets the error status of the image load.
Constructors
this(string filename)Loads a BMP image from a file.
Destructors
~thisDestroys the BMP image.

GIF image loaded from file.

GIF supports animation and transparency (1-bit alpha).

Note

Only the first frame of animated GIFs is loaded.

Example:

auto img = new GifImage("animation.gif");
if (img.isValid) {
   writefln("Loaded %dx%d GIF", img.width, img.height);
}

Fields
FltkGifImage _gifHandle
Methods
FltkGifImage gifHandle() @safe nothrow @nogcReturns the underlying GIF image handle.
bool isValid() const @trusted nothrow @nogcChecks if the GIF image loaded successfully.
int fail() const nothrow @nogcGets the error status of the image load.
Constructors
this(string filename)Loads a GIF image from a file.
Destructors
~thisDestroys the GIF image.

PNM image loaded from file.

PNM (Portable Any Map) is a family of simple image formats:

  • PBM (Portable Bitmap) - 1-bit monochrome
  • PGM (Portable Graymap) - grayscale
  • PPM (Portable Pixmap) - color

Both ASCII and binary formats are supported.

Example:

auto img = new PnmImage("image.ppm");
if (img.isValid) {
   writefln("Loaded %dx%d PNM", img.width, img.height);
}

Fields
FltkPnmImage _pnmHandle
Methods
FltkPnmImage pnmHandle() @safe nothrow @nogcReturns the underlying PNM image handle.
bool isValid() const @trusted nothrow @nogcChecks if the PNM image loaded successfully.
int fail() const nothrow @nogcGets the error status of the image load.
Constructors
this(string filename)Loads a PNM image from a file.
Destructors
~thisDestroys the PNM image.