From e76d2238bbe2fc9940258460ec8e577c3ff3f1b3 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 28 Apr 2023 09:08:34 -0400 Subject: ICC: Make number_of_components_in_color_space() external ...and make its return type unsigned. --- Userland/Libraries/LibGfx/ICC/Profile.cpp | 28 ++++++++++++++-------------- Userland/Libraries/LibGfx/ICC/Profile.h | 1 + 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Userland/Libraries/LibGfx/ICC/Profile.cpp b/Userland/Libraries/LibGfx/ICC/Profile.cpp index 983304c453..bd852cff4d 100644 --- a/Userland/Libraries/LibGfx/ICC/Profile.cpp +++ b/Userland/Libraries/LibGfx/ICC/Profile.cpp @@ -421,7 +421,19 @@ StringView data_color_space_name(ColorSpace color_space) VERIFY_NOT_REACHED(); } -static int number_of_components_in_color_space(ColorSpace color_space) +StringView profile_connection_space_name(ColorSpace color_space) +{ + switch (color_space) { + case ColorSpace::PCSXYZ: + return "PCSXYZ"sv; + case ColorSpace::PCSLAB: + return "PCSLAB"sv; + default: + return data_color_space_name(color_space); + } +} + +unsigned number_of_components_in_color_space(ColorSpace color_space) { switch (color_space) { case ColorSpace::Gray: @@ -468,18 +480,6 @@ static int number_of_components_in_color_space(ColorSpace color_space) VERIFY_NOT_REACHED(); } -StringView profile_connection_space_name(ColorSpace color_space) -{ - switch (color_space) { - case ColorSpace::PCSXYZ: - return "PCSXYZ"sv; - case ColorSpace::PCSLAB: - return "PCSLAB"sv; - default: - return data_color_space_name(color_space); - } -} - StringView primary_platform_name(PrimaryPlatform primary_platform) { switch (primary_platform) { @@ -1178,7 +1178,7 @@ ErrorOr Profile::check_tag_types() // "The device representation corresponds to the header’s “data colour space” field. // This representation should be consistent with the “number of device coordinates” field in the namedColor2Type. // If this field is 0, device coordinates are not provided." - if (int number_of_device_coordinates = static_cast(*type.value()).number_of_device_coordinates(); + if (auto number_of_device_coordinates = static_cast(*type.value()).number_of_device_coordinates(); number_of_device_coordinates != 0 && number_of_device_coordinates != number_of_components_in_color_space(data_color_space())) { return Error::from_string_literal("ICC::Profile: namedColor2Tag number of device coordinates inconsistent with data color space"); } diff --git a/Userland/Libraries/LibGfx/ICC/Profile.h b/Userland/Libraries/LibGfx/ICC/Profile.h index 709fd97423..864074b8b7 100644 --- a/Userland/Libraries/LibGfx/ICC/Profile.h +++ b/Userland/Libraries/LibGfx/ICC/Profile.h @@ -87,6 +87,7 @@ enum class ColorSpace : u32 { }; StringView data_color_space_name(ColorSpace); StringView profile_connection_space_name(ColorSpace); +unsigned number_of_components_in_color_space(ColorSpace); // ICC v4, 7.2.10 Primary platform field, Table 20 — Primary platforms enum class PrimaryPlatform : u32 { -- cgit v1.2.3