-
-
Notifications
You must be signed in to change notification settings - Fork 859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for decoding tiff images with cmyk pixel data #2268
Conversation
@@ -31,8 +31,8 @@ public override void Decode(ReadOnlySpan<byte> data, Buffer2D<TPixel> pixels, in | |||
for (int x = 0; x < pixelRow.Length; x++) | |||
{ | |||
float l = (data[offset] & 0xFF) * 100f * Inv255; | |||
var lab = new CieLab(l, (sbyte)data[offset + 1], (sbyte)data[offset + 2]); | |||
var rgb = ColorSpaceConverter.ToRgb(lab); | |||
CieLab lab = new(l, (sbyte)data[offset + 1], (sbyte)data[offset + 2]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious to how the data is encoded here.
The CieLab A
, B
values usually range from −128 to 127 when working with integer values.
Casting to sbyte
and using overflow is a neat trick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To cite the spec:
Tiff is defined such that each quantity be encoded with 8 bits. This provides 256 levels of L* lightness;
256 levels (+/- 127) of a*, and 256 levels (+/- 127) of b*.
...
Limiting the theoretically unbounded a* and b*
ranges to +/- 127 allows encoding in 8 bits without eliminating any but the most
saturated self-luminous colors. It is anticipated that the rare specialized applications
requiring support of these extreme cases would be unlikely to use CIELAB
anyway. All object colors, in fact all colors within the theoretical MacAdam limits,
fall within the +/- 127 a*/b* range.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Prerequisites
Description
This PR adds support for decoding tiff images with cmyk pixel data.
Related issue: #2263