mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17:45 +00:00
LibGfx: Move CIELAB to its own file
This commit is contained in:
parent
22202715fc
commit
adec1abf81
4 changed files with 22 additions and 7 deletions
|
@ -175,7 +175,7 @@ TEST_CASE(to_lab)
|
||||||
//
|
//
|
||||||
// new Color("srgb", [1, 1, 1]).lab.toString();
|
// new Color("srgb", [1, 1, 1]).lab.toString();
|
||||||
|
|
||||||
Gfx::ICC::Profile::CIELAB expected[] = {
|
Gfx::CIELAB expected[] = {
|
||||||
{ 0, 0, 0 },
|
{ 0, 0, 0 },
|
||||||
{ 54.29054294696968, 80.80492033462421, 69.89098825896275 },
|
{ 54.29054294696968, 80.80492033462421, 69.89098825896275 },
|
||||||
{ 87.81853633115202, -79.27108223854806, 80.99459785152247 },
|
{ 87.81853633115202, -79.27108223854806, 80.99459785152247 },
|
||||||
|
|
18
Userland/Libraries/LibGfx/CIELAB.h
Normal file
18
Userland/Libraries/LibGfx/CIELAB.h
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023, Nico Weber <thakis@chromium.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Gfx {
|
||||||
|
|
||||||
|
// https://en.wikipedia.org/wiki/CIELAB_color_space
|
||||||
|
struct CIELAB {
|
||||||
|
float L; // L*
|
||||||
|
float a; // a*
|
||||||
|
float b; // b*
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/Endian.h>
|
#include <AK/Endian.h>
|
||||||
|
#include <LibGfx/CIELAB.h>
|
||||||
#include <LibGfx/ICC/BinaryFormat.h>
|
#include <LibGfx/ICC/BinaryFormat.h>
|
||||||
#include <LibGfx/ICC/Profile.h>
|
#include <LibGfx/ICC/Profile.h>
|
||||||
#include <LibGfx/ICC/Tags.h>
|
#include <LibGfx/ICC/Tags.h>
|
||||||
|
@ -1470,7 +1471,7 @@ ErrorOr<FloatVector3> Profile::to_pcs(ReadonlyBytes color)
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<Profile::CIELAB> Profile::to_lab(ReadonlyBytes color)
|
ErrorOr<CIELAB> Profile::to_lab(ReadonlyBytes color)
|
||||||
{
|
{
|
||||||
auto pcs = TRY(to_pcs(color));
|
auto pcs = TRY(to_pcs(color));
|
||||||
if (connection_space() == ColorSpace::PCSLAB)
|
if (connection_space() == ColorSpace::PCSLAB)
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <AK/Span.h>
|
#include <AK/Span.h>
|
||||||
#include <AK/URL.h>
|
#include <AK/URL.h>
|
||||||
#include <LibCrypto/Hash/MD5.h>
|
#include <LibCrypto/Hash/MD5.h>
|
||||||
|
#include <LibGfx/CIELAB.h>
|
||||||
#include <LibGfx/ICC/DistinctFourCC.h>
|
#include <LibGfx/ICC/DistinctFourCC.h>
|
||||||
#include <LibGfx/ICC/TagTypes.h>
|
#include <LibGfx/ICC/TagTypes.h>
|
||||||
#include <LibGfx/Vector3.h>
|
#include <LibGfx/Vector3.h>
|
||||||
|
@ -266,11 +267,6 @@ public:
|
||||||
// Call connection_space() to find out the space the result is in.
|
// Call connection_space() to find out the space the result is in.
|
||||||
ErrorOr<FloatVector3> to_pcs(ReadonlyBytes);
|
ErrorOr<FloatVector3> to_pcs(ReadonlyBytes);
|
||||||
|
|
||||||
struct CIELAB {
|
|
||||||
float L; // L*
|
|
||||||
float a; // a*
|
|
||||||
float b; // b*
|
|
||||||
};
|
|
||||||
ErrorOr<CIELAB> to_lab(ReadonlyBytes);
|
ErrorOr<CIELAB> to_lab(ReadonlyBytes);
|
||||||
|
|
||||||
// Only call these if you know that this is an RGB matrix-based profile.
|
// Only call these if you know that this is an RGB matrix-based profile.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue