Added in commit 415f869f20 to drop a
workaround from commit bac042db39.
This line was not a part of the workaround and looks completely
unrelated. I assume that's just a commit mistake. :-)
and use babl to convert between profiles if possible. With the default
BABL_TOLERANCE this is about 5 times faster than lcms on my test image.
Using babl can be disabled by setting GIMP_COLOR_TRANSFORM_DISABLE_BABL.
which takes a GimpColorProfile and a Babl format, and returns a new
format which uses the profile's RGB primaries and TRC, and the
original format's pixel layout; or NULL if babl couldn't create a
space from the profile's ICC data.
Use cmsFLAGS_NOOPTIMIZE only for actual image buffer or single color
transforms, but not for previews or the image display. Makes things a
lot more responsive again.
It doesn't really "fail", we check if an error was logged during
transform creation and get rid of the transform even if lcms returned
a pointer. This totally sucks but is better than crashing on a corrupt
transform.
Which takes two profiles and returns TRUE if converting between
them works correctly without a GimpColorTransform. Use it in
gimp_color_transform_new() to return a NULL transform if none
is needed. Took the code from gimp-gegl-loops.c.
which encapsulates a cmsHTRANSFORM and does all the pixel format
conversion magic. It has API to create transforms and proofing
transforms, and to convert pixels arrays and GeglBuffers.
Before, each place which has a transform had to keep around the
transform and its input and output Babl formats, and had to implement
lots of stuff itself. Now all that lives in GimpColorTransform,
removing lots of logic from many places, and pretty much removing lcms
from the public API entirely.
This removes including <lcms2.h>, LCMS_LIBS and LCMS_CFLAGS from
almost all directories and potentially allows to replace lcms by
something else.
Trick lcms into converting cairo-RGB24 pixels directly, by using
TYPE_BGRA_8 on little endian and TYPE_ARGB_8 on big endian. They have
the same byte order, and the alpha channel (ignored by lcms anyway)
takes the place of the unused byte of cairo-RGB24.
This saves two babl conversions around cmsDoTransform().
Return "R'G'B'[A] u8" and "TYPE_RGB[A]_8" and babl and lcms formats.
I'm not sure which code triggered the warning about an unhandled
format, but now it handles indexed images too.
Rename profile constructors to say "d65_gray" instead of just "gray",
"srgb_trc" instead of "srgb_gamma", and drop the "srgb" from
"srgb_linear" because we now say "d65". This should be a naming scheme
that doesn't conflict with whatever future functions we might add.
Support creating linear/sRGB-gamma variants of gray profiles and
rename gimp_color_profile_new_linear_rgb_from_color_profile() to
gimp_color_profile_new_linear_gamma_from_color_profile() because it's
not RGB-specific any longer.
Add gimp_color_profile_new_srgb_gray() and
gimp_color_profile_new_linear_gray().
I know "srgb_gray" sounds odd but it's better than
"gray_with_srgb_trc"...
Please review, I have no clue if that code is right.
Add two private functions which are currently unused but will
become public once it's clear where exactly we need them:
gimp_color_profile_get_rgb_matrix_colorants(): returns a GimpMatrix2
with the RGB colorants.
gimp_color_profile_new_foobar(): takes an existing profile and creates
a new one with the same RGB colorants but a linear gamma TRC. To be
renamed and made more general.
Fix gimp_color_profile_get_format() to return the right format for
"cairo-RGB24": simply check for the more special cairo formats first,
then check for the general RGB models. Found by Massimo.