fltk.images.shared_

FLTK Shared Image Class

This module provides the SharedImage class that wraps FLTK's Fl_Shared_Image. SharedImage provides reference-counted, cached image loading.

Shared images are automatically cached by FLTK, so loading the same file multiple times returns the same image data without re-reading from disk.

Authors

Dejan Lekić

License

BSD-3-Clause

Types 1

Reference-counted cached image.

SharedImage loads images from files and caches them. If the same file is requested again, the cached version is returned instead of re-loading from disk.

The image format is automatically detected from the file contents. Supported formats depend on what FLTK was compiled with, but typically include PNG, JPEG, BMP, and GIF.

Example:

// Load an image (auto-detects format)
auto img = SharedImage.get("photo.png");
if (img !is null && img.isValid) {
   writefln("Loaded %dx%d image", img.width, img.height);
   // ... use the image ...
   img.release();  // Release when done
}

// Check if image is already cached
auto cached = SharedImage.find("photo.png");
if (cached !is null) {
   writeln("Image is in cache");
}

Fields
FltkSharedImage _sharedHandle
Methods
SharedImage get(string filename)Gets a shared image from file, loading if not cached.
SharedImage find(string filename)Finds a shared image in the cache without loading.
void release() nothrow @nogcReleases a reference to this shared image.
FltkSharedImage sharedHandle() @safe nothrow @nogcReturns the underlying shared image handle.
bool isValid() const @safe nothrow @nogcChecks if this shared image is valid.
Constructors
this(FltkSharedImage handle)Private constructor - use get() or find() factory methods.
Destructors
~thisDestructor - releases the shared image reference.