From 8bf54227ae68f448f241d894af68f4e6719b5725 Mon Sep 17 00:00:00 2001 From: Elias Batek Date: Sun, 6 Oct 2024 20:31:01 +0200 Subject: [PATCH] Add documentation for the crop functions --- pixmappaint.d | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pixmappaint.d b/pixmappaint.d index 66d6790..8c14359 100644 --- a/pixmappaint.d +++ b/pixmappaint.d @@ -1577,20 +1577,32 @@ void invert(Pixmap pixmap) @nogc { } } -/// +/++ + Crops an image and stores the result in the provided target Pixmap. + + The size of the area to crop the image to + is derived from the size of the target. + +/ void crop(const Pixmap source, Pixmap target, Point offset = Point(0, 0)) @nogc { auto src = const(SubPixmap)(source, target.size, offset); src.extractToPixmapCopyImpl(target); } -/// +/++ + Crops an image and stores the result in a newly allocated Pixmap. + +/ Pixmap cropNew(const Pixmap source, Size targetSize, Point offset = Point(0, 0)) { auto target = Pixmap(targetSize); crop(source, target, offset); return target; } -/// +/++ + Crops an image and stores the result in the source buffer. + + The source pixmap structure is passed by ref and gets with a size-adjusted + structure using a slice of the same underlying memory. + +/ void cropInplace(ref Pixmap source, Size targetSize, Point offset = Point(0, 0)) @nogc { auto src = const(SubPixmap)(source, targetSize, offset); source = src.extractToPixmap(source);