aboutsummaryrefslogtreecommitdiff
path: root/fiv-io-profile.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2024-01-26 19:53:55 +0100
committerPřemysl Eric Janouch <p@janouch.name>2024-01-26 19:55:31 +0100
commitae8dc3070a44c2fad90cba8037e54d1a575240df (patch)
treef226ebf407970facffe168c8410e9d9acd3763b2 /fiv-io-profile.c
parent3c8a280546e3ec19c3246afada2d488880fc3222 (diff)
downloadfiv-ae8dc3070a44c2fad90cba8037e54d1a575240df.tar.gz
fiv-ae8dc3070a44c2fad90cba8037e54d1a575240df.tar.xz
fiv-ae8dc3070a44c2fad90cba8037e54d1a575240df.zip
Partially circumvent a Little CMS bug
Diffstat (limited to 'fiv-io-profile.c')
-rw-r--r--fiv-io-profile.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/fiv-io-profile.c b/fiv-io-profile.c
index 84b310e..2c6f345 100644
--- a/fiv-io-profile.c
+++ b/fiv-io-profile.c
@@ -30,12 +30,16 @@
#include <lcms2_fast_float.h>
#endif // HAVE_LCMS2_FAST_FLOAT
+// https://github.com/mm2/Little-CMS/issues/430
+static bool g_broken_cms_premul;
+
void
fiv_io_profile_init(void)
{
// TODO(p): Use Little CMS with contexts instead.
#ifdef HAVE_LCMS2_FAST_FLOAT
- cmsPluginTHR(NULL, cmsFastFloatExtensions());
+ if (cmsPluginTHR(NULL, cmsFastFloatExtensions()))
+ g_broken_cms_premul = LCMS_VERSION <= 2160;
#endif // HAVE_LCMS2_FAST_FLOAT
}
@@ -300,6 +304,8 @@ fiv_io_profile_argb32(FivIoImage *image,
{
g_return_if_fail(image->format == CAIRO_FORMAT_ARGB32);
+ // TODO: With g_no_cms_premultiplication,
+ // this probably also needs to be wrapped in un-premultiplication.
fiv_io_profile_rgb_direct(image->data, image->width, image->height,
source, target,
FIV_IO_PROFILE_ARGB32_PREMUL, FIV_IO_PROFILE_ARGB32_PREMUL);
@@ -311,6 +317,9 @@ fiv_io_profile_argb32_premultiply(
{
if (image->format != CAIRO_FORMAT_ARGB32) {
fiv_io_profile_xrgb32(image, source, target);
+ } else if (g_broken_cms_premul) {
+ fiv_io_profile_xrgb32(image, source, target);
+ fiv_io_premultiply_argb32(image);
} else if (!fiv_io_profile_rgb_direct(image->data,
image->width, image->height, source, target,
FIV_IO_PROFILE_ARGB32, FIV_IO_PROFILE_ARGB32_PREMUL)) {