From 9d0c6e1d0c5b3d709feeab33447d5a4f14bf020c Mon Sep 17 00:00:00 2001 From: Elias Batek Date: Mon, 6 May 2024 00:49:20 +0200 Subject: [PATCH] Add functions for loading image-data from arsd.color --- pixmappaint.d | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pixmappaint.d b/pixmappaint.d index 52846c5..1cc9701 100644 --- a/pixmappaint.d +++ b/pixmappaint.d @@ -112,6 +112,26 @@ struct Pixmap { this.width = width; } + static { + /++ + Creates a Pixmap wrapping the pixel data from the provided `TrueColorImage`. + + Interoperability function: `arsd.color` + +/ + Pixmap fromTrueColorImage(TrueColorImage source) @nogc { + return Pixmap(source.imageData.colors, source.width); + } + + /++ + Creates a Pixmap wrapping the pixel data from the provided `MemoryImage`. + + Interoperability function: `arsd.color` + +/ + Pixmap fromMemoryImage(MemoryImage source) { + return fromTrueColorImage(source.getAsTrueColorImage()); + } + } + @safe pure nothrow @nogc: /// Height of the buffer, i.e. the number of lines