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.
License
BSD-3-Clause
Copyright
Copyright © 2025 DDN (D Developer Network) Members
class SharedImage
Types 1
classSharedImage : Image
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 _sharedHandleMethods
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.Constructors
this(FltkSharedImage handle)Private constructor - use get() or find() factory methods.Destructors
~thisDestructor - releases the shared image reference.