libgimpcolor: add new object GimpColorTransform
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.
This commit is contained in:
@ -479,20 +479,16 @@ get_display_profile (GtkWidget *widget,
|
||||
return profile;
|
||||
}
|
||||
|
||||
GimpColorTransform
|
||||
gimp_widget_get_color_transform (GtkWidget *widget,
|
||||
GimpColorConfig *config,
|
||||
GimpColorProfile *src_profile,
|
||||
const Babl **src_format,
|
||||
const Babl **dest_format)
|
||||
GimpColorTransform *
|
||||
gimp_widget_get_color_transform (GtkWidget *widget,
|
||||
GimpColorConfig *config,
|
||||
GimpColorProfile *src_profile,
|
||||
const Babl *src_format,
|
||||
const Babl *dest_format)
|
||||
{
|
||||
GimpColorTransform transform = NULL;
|
||||
GimpColorTransform *transform = NULL;
|
||||
GimpColorProfile *dest_profile = NULL;
|
||||
GimpColorProfile *proof_profile = NULL;
|
||||
cmsHPROFILE src_lcms;
|
||||
cmsHPROFILE dest_lcms;
|
||||
cmsUInt32Number lcms_src_format;
|
||||
cmsUInt32Number lcms_dest_format;
|
||||
cmsUInt16Number alarmCodes[cmsMAXCHANNELS] = { 0, };
|
||||
|
||||
g_return_val_if_fail (widget == NULL || GTK_IS_WIDGET (widget), NULL);
|
||||
@ -515,19 +511,10 @@ gimp_widget_get_color_transform (GtkWidget *widget,
|
||||
break;
|
||||
}
|
||||
|
||||
src_lcms = gimp_color_profile_get_lcms_profile (src_profile);
|
||||
dest_lcms = gimp_color_profile_get_lcms_profile (dest_profile);
|
||||
|
||||
*src_format = gimp_color_profile_get_format (*src_format, &lcms_src_format);
|
||||
*dest_format = gimp_color_profile_get_format (*dest_format, &lcms_dest_format);
|
||||
|
||||
if (proof_profile)
|
||||
{
|
||||
cmsHPROFILE proof_lcms;
|
||||
cmsUInt32Number softproof_flags = cmsFLAGS_SOFTPROOFING;
|
||||
|
||||
proof_lcms = gimp_color_profile_get_lcms_profile (proof_profile);
|
||||
|
||||
if (config->simulation_use_black_point_compensation)
|
||||
{
|
||||
softproof_flags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
|
||||
@ -548,28 +535,28 @@ gimp_widget_get_color_transform (GtkWidget *widget,
|
||||
cmsSetAlarmCodes (alarmCodes);
|
||||
}
|
||||
|
||||
transform = cmsCreateProofingTransform (src_lcms, lcms_src_format,
|
||||
dest_lcms, lcms_dest_format,
|
||||
proof_lcms,
|
||||
config->simulation_intent,
|
||||
config->display_intent,
|
||||
softproof_flags);
|
||||
transform = gimp_color_transform_new_proofing (src_profile, src_format,
|
||||
dest_profile, dest_format,
|
||||
proof_profile,
|
||||
config->simulation_intent,
|
||||
config->display_intent,
|
||||
softproof_flags);
|
||||
|
||||
g_object_unref (proof_profile);
|
||||
}
|
||||
else if (! gimp_color_profile_is_equal (src_profile, dest_profile))
|
||||
{
|
||||
cmsUInt32Number display_flags = 0;
|
||||
guint32 display_flags = 0;
|
||||
|
||||
if (config->display_use_black_point_compensation)
|
||||
{
|
||||
display_flags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
|
||||
}
|
||||
|
||||
transform = cmsCreateTransform (src_lcms, lcms_src_format,
|
||||
dest_lcms, lcms_dest_format,
|
||||
config->display_intent,
|
||||
display_flags);
|
||||
transform = gimp_color_transform_new (src_profile, src_format,
|
||||
dest_profile, dest_format,
|
||||
config->display_intent,
|
||||
display_flags);
|
||||
}
|
||||
|
||||
g_object_unref (dest_profile);
|
||||
|
||||
Reference in New Issue
Block a user