summaryrefslogtreecommitdiff
path: root/dmagick/Geometry.d
diff options
context:
space:
mode:
Diffstat (limited to 'dmagick/Geometry.d')
-rw-r--r--dmagick/Geometry.d22
1 files changed, 22 insertions, 0 deletions
diff --git a/dmagick/Geometry.d b/dmagick/Geometry.d
index 2ccab99..261c691 100644
--- a/dmagick/Geometry.d
+++ b/dmagick/Geometry.d
@@ -120,6 +120,28 @@ struct Geometry
assert( geo.toString == "200x150!-50+25");
}
+ /**
+ * Calculate the absolute width and height based on the flags,
+ * and the profided width and height.
+ */
+ Geometry toAbsolute(size_t width, size_t height)
+ {
+ ssize_t x, y;
+
+ ParseMetaGeometry(toStringz(toString()), &x, &y, &width, &height);
+
+ return Geometry(width, height, x, y);
+ }
+
+ unittest
+ {
+ Geometry percentage = Geometry("50%");
+ Geometry absolute = percentage.toAbsolute(100, 100);
+
+ assert(absolute.width == 50);
+ assert(absolute.height == 50);
+ }
+
RectangleInfo rectangleInfo()
{
RectangleInfo info;