Commit Graph
8 Commits
Author SHA1 Message Date
dotCooCoo 0ca8b8e141 texture: check the HDR side limit in craft-hdr
Set craft_hdr::Limits::max_axis from Limits::max_side and drop the
separate resolution-line parser. A side over the limit is now
DecodeError::LimitExceeded ("axis length"), reported before any pixel
memory is allocated.
2026-11-28 02:33:21 -08:00
dotCooCoo ac39a088e7 Merge main into feat/craft-texture-decode 2026-11-28 01:39:11 -08:00
dotCooCoo ba2f2a8eda image-codecs: bound TIFF compressed chunks by the allocation limit 2026-11-26 17:03:28 -08:00
dotCooCoo c0f1c226e3 craft-texture: sRGB tests check the standard only, under tests/it/
The comparisons with craft-cms, craft-mesh and craft-psd and their
dev-dependencies are removed. The tests of the pair against
IEC 61966-2-1 move to tests/it/srgb.rs, linked through tests/it/main.rs.
2026-11-25 19:25:15 -08:00
dotCooCoo 750d4b49f4 texture: refuse every deep EXR part and read CR-only HDR header ends
`decode::exr` now refuses a file when any part is deep, not only when the
picked color part is, as its documentation says. A file with a flat RGB
part beside a deep part decoded before.

`hdr_size` now treats a line of carriage returns alone as the empty line
that ends a Radiance header, as `craft_hdr::decode` does. A header ending
in `\r\r\n` skipped the side check before the decoder ran.
2026-11-16 10:30:40 -08:00
dotCooCoo 259549fe93 craft-texture: sRGB tests fail on a difference that is not finite
worst() now asserts that each difference is finite and names the code it
is at. Before, a NaN difference never replaced the maximum, so a pair that
returned NaN at every code passed the tolerance checks. A new test checks
that worst() fails on a NaN difference.
2026-11-15 17:09:26 -08:00
dotCooCoo a536024711 craft-texture: decode PNG, TIFF, Radiance HDR and OpenEXR into float planes
New optional features png, tiff, hdr and exr (decode enables all four) add
the decode module. decode::png and decode::tiff read through
craft-image-codecs at the stored sample depth, so 16-bit samples become
v / 65535 and keep all 65536 levels instead of passing through 8 bits.
decode::hdr reads through craft-hdr and decode::exr through craft-exr;
values above 1, negative values and OpenEXR NaN and infinities are kept.

Each result carries a transfer tag (Encoded, Linear or Unknown, from the
PNG cICP chunk, an ICC profile or the format) and an alpha tag (OpenEXR is
premultiplied, TIFF associated alpha is converted to straight). No
transfer function is applied.

The plane is checked against Limits before it is reserved, with one
fallible allocation. The format decoders get the same side, pixel and byte
limits; a Radiance HDR side over max_side is refused from the header, and
OpenEXR counts every declared channel toward max_bytes. A TIFF whose image
data ends early, CMYK and Lab TIFF, and OpenEXR files with a deep part are
errors. The decoding features build for wasm32-unknown-unknown.
2026-11-14 15:11:28 -08:00
dotCooCoo 3a710e4c62 craft-texture: tests check the sRGB pair against the standard, craft-cms, craft-mesh and craft-psd
The new tests in crates/texture/tests/srgb.rs compare linear_to_srgb and
srgb_to_linear with the IEC 61966-2-1 formulas at every 8-bit and 16-bit
code, check both thresholds (0.0031308 and 0.04045) and their neighbors,
round trips, and that the outputs do not decrease over the code grids.
They pin the behavior outside [0, 1]: negative values stay on the linear
segment, values above 1 follow the power segment, infinities keep their
sign and NaN stays NaN.

craft-mesh's pair and craft-psd's float::srgb_encode must match bit for
bit, and craft-cms's srgb_trc() curve within 2.4e-7. craft-cms,
craft-mesh and craft-psd are dev-dependencies of craft-texture.
2026-11-14 13:41:12 -08:00