1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:17:35 +00:00

LibGfx: Add a XYZ->XYZNumber conversion constructor

This is useful for converting XYZs back to the on-disk format.
This commit is contained in:
Nico Weber 2023-02-17 13:12:12 -05:00 committed by Andrew Kaster
parent 0ca620a286
commit 0ab3f45135

View file

@ -10,6 +10,7 @@
#include <LibGfx/ICC/DistinctFourCC.h> #include <LibGfx/ICC/DistinctFourCC.h>
#include <LibGfx/ICC/Profile.h> #include <LibGfx/ICC/Profile.h>
#include <LibGfx/ICC/TagTypes.h> #include <LibGfx/ICC/TagTypes.h>
#include <math.h>
namespace Gfx::ICC { namespace Gfx::ICC {
@ -36,6 +37,15 @@ struct XYZNumber {
BigEndian<s15Fixed16Number> y; BigEndian<s15Fixed16Number> y;
BigEndian<s15Fixed16Number> z; BigEndian<s15Fixed16Number> 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 operator XYZ() const
{ {
return XYZ { x / (double)0x1'0000, y / (double)0x1'0000, z / (double)0x1'0000 }; return XYZ { x / (double)0x1'0000, y / (double)0x1'0000, z / (double)0x1'0000 };