fltk.images.pixmap

FLTK Pixmap Image Class

This module provides the Pixmap class that wraps FLTK's Fl_Pixmap. Pixmaps are color images stored in XPM (X PixMap) format, commonly used for icons and small graphics with transparency.

The Pixmap class provides:

  • RAII-based resource management
  • Construction from XPM format data
  • Property-based access to dimensions

XPM Format: XPM (X PixMap) is a text-based color image format. It consists of an array of strings where:

  • First string: "width height num_colors chars_per_pixel"
  • Next num_colors strings: color definitions
  • Remaining strings: pixel data rows

    Authors

    Dejan Lekić

    License

    BSD-3-Clause
class Pixmap

Types 1

classPixmap : Image

Color pixmap image in XPM format.

Pixmap images are useful for icons and small graphics that need color and transparency support. XPM format is text-based and easy to embed in source code.

Note

The XPM data passed to the constructor must remain valid

for the lifetime of the Pixmap object, as FLTK does not copy the data.

Example:

// XPM data for a simple 2x2 red/blue pattern
static immutable(char)*[] xpmData = [
   "2 2 2 1",      // 2x2, 2 colors, 1 char per pixel
   "r c #FF0000",  // 'r' = red
   "b c #0000FF",  // 'b' = blue
   "rb",           // row 1
   "br"            // row 2
];
auto pm = new Pixmap(xpmData);
if (pm.isValid) {
   writefln("Created %dx%d pixmap", pm.width, pm.height);
}

Fields
FltkPixmap _pixmapHandle
const(char) *[] _dataRefStore reference to data to prevent GC collection
Methods
FltkPixmap pixmapHandle() @safe nothrow @nogcReturns the underlying pixmap handle.
bool isValid() const @safe nothrow @nogcChecks if the pixmap was created successfully.
Constructors
this(const(char) *[] data)Creates a pixmap from XPM data.
this(const(char *) * data)Creates a pixmap from a raw pointer to XPM data.
Destructors
~thisDestroys the pixmap and releases resources.