Skip to content

420996 438655 TIFF: add floating point and premultiplied alpha support

Amy spark requested to merge lsegovia/krita:work/amyspark/tiff into master

This adds support for premultiplied alpha in TIFF.

Before this commit, TIFF files with such an alpha channel would be visually OK; however, with the eyedropper tool, one can check that a flat area that only varies in its alpha changes the colour channel values, which is not the correct behaviour for an editing tool.

Additionally, as requested by Dmitry, this also includes handling denormal alpha values as it's done for EXR. Researching how to fix this led me to filing a separate bug for incorrect floating point support. We have a mix of floating-point compatible and integer-only code, that this MR removes in favour of pure templated code.

BUG: 420996

BUG: 438655

Test Plan

Create an alpha-based image. Convert it to a TIFF with premultiplied alpha following the instructions here. With ImageMagick, it should be like this:

convert in.png -background black -alpha Remove in.png -compose Copy_Opacity -composite -define tiff:alpha=associated out.tif

The following examples are a flat red tile with linearly decreasing alpha. The PNG file is the original, the TIF has been premodulated with the script above: in.png out.tif

Open out.tif in Krita, and check that its colour channels values match the original (255 0 0).

Without this patch, check that its colour values instead match the associated alpha channel's value.

This MR also includes a new entry to the TIFF test suite.

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.
Edited by Amy spark

Merge request reports