From 0ab3f45135e33e2df054594bfa1baa412bdaa9f1 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 17 Feb 2023 13:12:12 -0500 Subject: [PATCH] LibGfx: Add a XYZ->XYZNumber conversion constructor This is useful for converting XYZs back to the on-disk format. --- Userland/Libraries/LibGfx/ICC/BinaryFormat.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Userland/Libraries/LibGfx/ICC/BinaryFormat.h b/Userland/Libraries/LibGfx/ICC/BinaryFormat.h index 1ee3302380..c9952a4b62 100644 --- a/Userland/Libraries/LibGfx/ICC/BinaryFormat.h +++ b/Userland/Libraries/LibGfx/ICC/BinaryFormat.h @@ -10,6 +10,7 @@ #include #include #include +#include namespace Gfx::ICC { @@ -36,6 +37,15 @@ struct XYZNumber { BigEndian y; BigEndian z; + XYZNumber() = default; + + XYZNumber(XYZ const& xyz) + : x(round(xyz.x * 0x1'0000)) + , y(round(xyz.y * 0x1'0000)) + , z(round(xyz.z * 0x1'0000)) + { + } + operator XYZ() const { return XYZ { x / (double)0x1'0000, y / (double)0x1'0000, z / (double)0x1'0000 };