fltk.images.image

FLTK Image Base Class

This module provides the base Image class that wraps FLTK's Fl_Image. All other image types inherit from this class.

The Image class provides:

  • RAII-based resource management
  • Property-based access to dimensions (width, height, depth)
  • Image manipulation methods (copy, colorAverage, inactive, desaturate)
  • Pixel data access

    Authors

    Dejan Lekić

    License

    BSD-3-Clause
class Image

Types 1

classImage

Base class for all FLTK images.

This class wraps a low-level FltkImage handle and provides idiomatic D access to image properties and methods. It manages the lifetime of the underlying image handle using RAII.

Example:

// Usually you work with derived classes like PngImage or JpegImage
auto png = new PngImage("photo.png");
writefln("Size: %dx%d", png.width, png.height);
auto scaled = png.copy(100, 100);  // Create scaled copy

Fields
FltkImage _handleThe underlying low-level image handle
bool _ownsHandleWhether this instance owns the handle and should delete it
Methods
FltkImage handle() @safe nothrow @nogcReturns the underlying low-level handle.
bool isValid() const @safe nothrow @nogcChecks if this image has a valid handle.
int width() const nothrow @nogcGets the image width.
int height() const nothrow @nogcGets the image height.
int depth() const nothrow @nogcGets the image depth (bytes per pixel).
int lineSize() const nothrow @nogcGets the image line data size.
int count() const nothrow @nogcGets the number of data elements.
size_t dataSize() const nothrow @nogcGets the total size of the image data in bytes.
const(ubyte) * data() const nothrow @nogcGets a pointer to the raw pixel data.
Image copy(int newWidth = 0, int newHeight = 0)Creates a copy of the image, optionally scaled.
void colorAverage(uint color, float blend) nothrow @nogcApplies a color average to the image in place.
void inactive() nothrow @nogcConverts the image to an inactive (grayed) version in place.
void desaturate() nothrow @nogcDesaturates the image in place.
Constructors
this(FltkImage handle, bool ownsHandle = true)Creates an Image wrapper around an existing handle.
Destructors
~thisDestroys the image and releases resources.