mirror of
https://github.com/storytold/photocraft.git
synced 2026-10-30 12:57:28 -06:00
PhotoCraft treats 32-bit documents as linear light (Transfer::for_document, Exposure, Photo Filter, PSD import), but Image > Mode > 32 Bits/Channel only rescaled the samples, so a converted 8-bit grey 128 stayed 0.502. Photoshop stores 0.2159 (measured in Photoshop 27.11: 32-bit float TIFF of an sRGB chart, every sample = the sRGB-to-linear value). The conversion now decodes colour samples through the document's tone curve after widening to 32 bits, and encodes them before narrowing (so no linear value is quantised to 8 or 16 bits). Alpha, masks and alpha channels keep their values. RGB and Grayscale only (the 32-bit modes). With it, Photoshop's 32-bit results match exactly for the conversion itself, Levels, Black & White (default), Brightness/Contrast and Colorize (were 40-80 levels off in sRGB terms). Adds Surface::map_color (colour samples only, including the default pixel) and makes Transfer::decode/encode public. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>