1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:47:37 +00:00

LibGfx/ICC: Implement conversion to PCS for AToB*Tags using mAB

...as long as the mAB tag doesn't have A curves and a CLUT.

With this, we can convert images that use AToB* tags to the profile
connection space (and then from there to, say, sRGB), if the AToB* tag
uses the mAB format.

We can't yet do this if the mAB tag has A curves or a CLUT.

We can't convert back from PCS to this space yet.

We don't yet handle AToB* tags that use mft1 or mft2 instead of mAB.
This commit is contained in:
Nico Weber 2023-10-20 08:42:32 -04:00 committed by Andreas Kling
parent 15bddf5de3
commit c25538b2e3
2 changed files with 82 additions and 4 deletions

View file

@ -1374,8 +1374,11 @@ static TagSignature forward_transform_tag_for_rendering_intent(RenderingIntent r
VERIFY_NOT_REACHED();
}
ErrorOr<FloatVector3> Profile::to_pcs_a_to_b(TagData const& tag_data, ReadonlyBytes) const
ErrorOr<FloatVector3> Profile::to_pcs_a_to_b(TagData const& tag_data, ReadonlyBytes color) const
{
// Assumes a "normal" device_class() (i.e. not DeviceLink).
VERIFY(number_of_components_in_color_space(connection_space()) == 3);
switch (tag_data.type()) {
case Lut16TagData::Type:
// FIXME
@ -1383,9 +1386,16 @@ ErrorOr<FloatVector3> Profile::to_pcs_a_to_b(TagData const& tag_data, ReadonlyBy
case Lut8TagData::Type:
// FIXME
return Error::from_string_literal("ICC::Profile::to_pcs: AToB*Tag handling for mft1 tags not yet implemented");
case LutAToBTagData::Type:
// FIXME
return Error::from_string_literal("ICC::Profile::to_pcs: AToB*Tag handling for mAB tags not yet implemented");
case LutAToBTagData::Type: {
auto const& a_to_b = static_cast<LutAToBTagData const&>(tag_data);
if (a_to_b.number_of_input_channels() != number_of_components_in_color_space(data_color_space()))
return Error::from_string_literal("ICC::Profile::to_pcs_a_to_b: mAB input channel count does not match color space size");
if (a_to_b.number_of_output_channels() != number_of_components_in_color_space(connection_space()))
return Error::from_string_literal("ICC::Profile::to_pcs_a_to_b: mAB output channel count does not match profile connection space size");
return a_to_b.evaluate(color);
}
}
VERIFY_NOT_REACHED();
}