fltk.imagesurface

Image surface for drawing to in-memory images.

This module provides D bindings for FLTK's Fl_Image_Surface class, which allows drawing graphics to an in-memory image. This is useful for creating images programmatically, capturing widget content, or rendering graphics to images for later use.

Example:

// Create an image surface the same size as a widget
auto surface = new ImageSurface(widget.w, widget.h);

// Make it the current drawing target
surface.setCurrent();

// Draw a white background
import fltk.draw;
setColor(Color.WHITE);
rectf(0, 0, widget.w, widget.h);

// Draw the widget
surface.draw(widget);

// Get the resulting image
auto image = surface.image();

// Clean up
destroy(surface);

Types 1

Surface for drawing graphics to an in-memory image.

ImageSurface allows recording graphics operations that can then be retrieved as an RGB image. This enables programmatic image creation, widget rendering to images, and offscreen drawing.

The surface supports high-resolution mode for Retina/HiDPI displays, which creates images at double resolution.

Fields
private ImageSurfacePtr handle_
Methods
ImageSurfacePtr handle() nothrow @nogcReturns the underlying image surface handle.
bool isValid() const nothrow @nogcChecks if the image surface handle is valid.
void setCurrent()Makes this surface the current drawing target.
void draw(Widget widget, int deltaX = 0, int deltaY = 0)Draws a widget to the image surface.
void drawDecoratedWindow(Window win, int deltaX = 0, int deltaY = 0)Draws a decorated window to the image surface.
ImagePtr image()Gets the resulting RGB image from the surface.
ImagePtr highresImage()Gets a high-resolution shared image from the surface.
Constructors
this(int w, int h, bool highres = false)Creates a new image surface with the given dimensions.
Destructors