460715 HEIF: fix import/export of Adobe RGB images
This MR fixes several issues in our color management system when dealing with images under the Adobe RGB color space.
Whenever KisImportExportManager detected and banned the Adobe RGB primaries through KisImportExportManager::fillStaticExportConfigurationProperties
, KisWdgOptionsHeif::setConfiguration
would instead fill an invalid value into the conversion policy. This wasn't caught by any of the handlers, which then caused invalid primaries to slip into the CICP writing code. Files thus exported would then crash the application deep inside IccColorProfile on import, because Little CMS will rightfully return a null profile for those cases.
This MR fixes the issue by adding the correct checks and assertions throughout:
- IccColorProfile (full assert on null profile and on invalid color space characterization)
- IccColorSpaceEngine (safe assertions and correct fallbacks were introduced for linear gamma profiles)
- HeifExport (safe assertion on invalid primaries when
conversionPolicy
is notKeepTheSame
, refusing to export the image)
Finally, the correct default value for the conversion policy (KeepTheSame
) was applied throughout the HEIF export code.
Test Plan
Create and attempt to export an Adobe RGB 1998 image through AVIF. Check that it can be exported and that the only conversion policy available is KeepTheSame.
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.