summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2023-02-10 10:13:26 -0500
committerLinus Groh <mail@linusgroh.de>2023-02-10 15:19:14 +0000
commit9f0f3f434f6e5ad1b020d297f16fb9b1a46ce35f (patch)
tree0e98bb29d9f5b0c9d709193195c8cd5760697e6f /Userland/Libraries/LibGfx
parentab5b61c3fefa57c7f689a22f988c0929bbb5a515 (diff)
downloadserenity-9f0f3f434f6e5ad1b020d297f16fb9b1a46ce35f.zip
LibGfx+icc: Stringify known signatureType values
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r--Userland/Libraries/LibGfx/ICC/TagTypes.cpp121
-rw-r--r--Userland/Libraries/LibGfx/ICC/TagTypes.h7
2 files changed, 128 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/ICC/TagTypes.cpp b/Userland/Libraries/LibGfx/ICC/TagTypes.cpp
index 94d0ec70d7..253fa74421 100644
--- a/Userland/Libraries/LibGfx/ICC/TagTypes.cpp
+++ b/Userland/Libraries/LibGfx/ICC/TagTypes.cpp
@@ -7,6 +7,7 @@
#include <AK/DeprecatedString.h>
#include <AK/Endian.h>
#include <LibGfx/ICC/TagTypes.h>
+#include <LibGfx/ICC/Tags.h>
#include <LibTextCodec/Decoder.h>
namespace Gfx::ICC {
@@ -975,6 +976,126 @@ ErrorOr<NonnullRefPtr<SignatureTagData>> SignatureTagData::from_bytes(ReadonlyBy
return adopt_ref(*new SignatureTagData(offset, size, signature));
}
+Optional<StringView> SignatureTagData::colorimetric_intent_image_state_signature_name(u32 colorimetric_intent_image_state)
+{
+ // Table 26 — colorimetricIntentImageStateTag signatures
+ switch (colorimetric_intent_image_state) {
+ case 0x73636F65: // 'scoe'
+ return "Scene colorimetry estimates"sv;
+ case 0x73617065: // 'sape'
+ return "Scene appearance estimates"sv;
+ case 0x66706365: // 'fpce'
+ return "Focal plane colorimetry estimates"sv;
+ case 0x72686F63: // 'rhoc'
+ return "Reflection hardcopy original colorimetry"sv;
+ case 0x72706F63: // 'rpoc'
+ return "Reflection print output colorimetry"sv;
+ }
+ // "Other image state specifications are reserved for future ICC use."
+ return {};
+}
+
+Optional<StringView> SignatureTagData::perceptual_rendering_intent_gamut_signature_name(u32 perceptual_rendering_intent_gamut)
+{
+ // Table 27 — Perceptual rendering intent gamut
+ switch (perceptual_rendering_intent_gamut) {
+ case 0x70726D67: // 'prmg'
+ return "Perceptual reference medium gamut"sv;
+ }
+ // "It is possible that the ICC will define other signature values in the future."
+ return {};
+}
+
+Optional<StringView> SignatureTagData::saturation_rendering_intent_gamut_signature_name(u32 saturation_rendering_intent_gamut)
+{
+ // Table 28 — Saturation rendering intent gamut
+ switch (saturation_rendering_intent_gamut) {
+ case 0x70726D67: // 'prmg'
+ return "Perceptual reference medium gamut"sv;
+ }
+ // "It is possible that the ICC will define other signature values in the future."
+ return {};
+}
+
+Optional<StringView> SignatureTagData::technology_signature_name(u32 technology)
+{
+ // Table 29 — Technology signatures
+ switch (technology) {
+ case 0x6673636E: // 'fscn'
+ return "Film scanner"sv;
+ case 0x6463616D: // 'dcam'
+ return "Digital camera"sv;
+ case 0x7273636E: // 'rscn'
+ return "Reflective scanner"sv;
+ case 0x696A6574: // 'ijet'
+ return "Ink jet printer"sv;
+ case 0x74776178: // 'twax'
+ return "Thermal wax printer"sv;
+ case 0x6570686F: // 'epho'
+ return "Electrophotographic printer"sv;
+ case 0x65737461: // 'esta'
+ return "Electrostatic printer"sv;
+ case 0x64737562: // 'dsub'
+ return "Dye sublimation printer"sv;
+ case 0x7270686F: // 'rpho'
+ return "Photographic paper printer"sv;
+ case 0x6670726E: // 'fprn'
+ return "Film writer"sv;
+ case 0x7669646D: // 'vidm'
+ return "Video monitor"sv;
+ case 0x76696463: // 'vidc'
+ return "Video camera"sv;
+ case 0x706A7476: // 'pjtv'
+ return "Projection television"sv;
+ case 0x43525420: // 'CRT '
+ return "Cathode ray tube display"sv;
+ case 0x504D4420: // 'PMD '
+ return "Passive matrix display"sv;
+ case 0x414D4420: // 'AMD '
+ return "Active matrix display"sv;
+ case 0x4C434420: // 'LCD '
+ return "Liquid crystal display"sv;
+ case 0x4F4C4544: // 'OLED'
+ return "Organic LED display"sv;
+ case 0x4B504344: // 'KPCD'
+ return "Photo CD"sv;
+ case 0x696D6773: // 'imgs'
+ return "Photographic image setter"sv;
+ case 0x67726176: // 'grav'
+ return "Gravure"sv;
+ case 0x6F666673: // 'offs'
+ return "Offset lithography"sv;
+ case 0x73696C6B: // 'silk'
+ return "Silkscreen"sv;
+ case 0x666C6578: // 'flex'
+ return "Flexography"sv;
+ case 0x6D706673: // 'mpfs'
+ return "Motion picture film scanner"sv;
+ case 0x6D706672: // 'mpfr'
+ return "Motion picture film recorder"sv;
+ case 0x646D7063: // 'dmpc'
+ return "Digital motion picture camera"sv;
+ case 0x64636A70: // 'dcpj'
+ return "Digital cinema projector"sv;
+ }
+ // The spec does *not* say that other values are reserved for future use, but it says that for
+ // all other tags using signatureType. So return a {} here too instead of VERIFY_NOT_REACHED().
+ return {};
+}
+
+Optional<StringView> SignatureTagData::name_for_tag(TagSignature tag)
+{
+ if (tag == colorimetricIntentImageStateTag)
+ return colorimetric_intent_image_state_signature_name(signature());
+ if (tag == perceptualRenderingIntentGamutTag)
+ return perceptual_rendering_intent_gamut_signature_name(signature());
+ if (tag == saturationRenderingIntentGamutTag)
+ return saturation_rendering_intent_gamut_signature_name(signature());
+ if (tag == technologyTag)
+ return technology_signature_name(signature());
+ return {};
+}
+
ErrorOr<NonnullRefPtr<TextTagData>> TextTagData::from_bytes(ReadonlyBytes bytes, u32 offset, u32 size)
{
// ICC v4, 10.24 textType
diff --git a/Userland/Libraries/LibGfx/ICC/TagTypes.h b/Userland/Libraries/LibGfx/ICC/TagTypes.h
index 75a6e2dd2d..60bd162e9f 100644
--- a/Userland/Libraries/LibGfx/ICC/TagTypes.h
+++ b/Userland/Libraries/LibGfx/ICC/TagTypes.h
@@ -695,6 +695,13 @@ public:
u32 signature() const { return m_signature; }
+ static Optional<StringView> colorimetric_intent_image_state_signature_name(u32);
+ static Optional<StringView> perceptual_rendering_intent_gamut_signature_name(u32);
+ static Optional<StringView> saturation_rendering_intent_gamut_signature_name(u32);
+ static Optional<StringView> technology_signature_name(u32);
+
+ Optional<StringView> name_for_tag(TagSignature);
+
private:
u32 m_signature;
};