Bug 675558 - switch from lcms-1 to lcms-2

Applied modified patch from Hartmut Kuhse which ports to lcms-2.
This commit is contained in:
Michael Natterer 2012-09-03 20:03:53 +02:00
parent b955205676
commit 8bbfc9e5cf
6 changed files with 219 additions and 55 deletions

View File

@ -61,7 +61,7 @@ m4_define([libcurl_required_version], [7.15.1])
m4_define([dbus_glib_required_version], [0.70])
m4_define([libgudev_required_version], [167])
m4_define([exif_required_version], [0.6.15])
m4_define([lcms_required_version], [1.16])
m4_define([lcms_required_version], [2.2])
m4_define([libpng_required_version], [1.2.37])
m4_define([liblzma_required_version], [5.0.0])
@ -1569,7 +1569,7 @@ AC_ARG_WITH(lcms, [ --without-lcms build without lcms support])
have_lcms="no (lcms support disabled)"
if test "x$with_lcms" != xno; then
have_lcms=yes
PKG_CHECK_MODULES(LCMS, lcms >= lcms_required_version,
PKG_CHECK_MODULES(LCMS, lcms2 >= lcms_required_version,
AC_DEFINE(HAVE_LCMS, 1, [Define to 1 if lcms is available])
LCMS='lcms$(EXEEXT)',
have_lcms="no (lcms not found or unusable)")

View File

@ -19,7 +19,7 @@
#include <glib.h> /* lcms.h uses the "inline" keyword */
#include <lcms.h>
#include <lcms2.h>
#include <gegl.h>
#include <gtk/gtk.h>
@ -152,8 +152,6 @@ colorsel_cmyk_class_init (ColorselCmykClass *klass)
selector_class->stock_id = GTK_STOCK_PRINT; /* FIXME */
selector_class->set_color = colorsel_cmyk_set_color;
selector_class->set_config = colorsel_cmyk_set_config;
cmsErrorAction (LCMS_ERROR_IGNORE);
}
static void
@ -392,10 +390,12 @@ colorsel_cmyk_config_changed (ColorselCmyk *module)
{
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (module);
GimpColorConfig *config = module->config;
DWORD flags = 0;
cmsUInt32Number flags = 0;
cmsUInt32Number descSize = 0;
cmsHPROFILE rgb_profile;
cmsHPROFILE cmyk_profile;
const gchar *name;
gchar *descData;
const gchar *name = NULL;
gchar *text;
if (module->rgb2cmyk)
@ -420,13 +420,47 @@ colorsel_cmyk_config_changed (ColorselCmyk *module)
! (cmyk_profile = cmsOpenProfileFromFile (config->cmyk_profile, "r")))
goto out;
name = cmsTakeProductDesc (cmyk_profile);
descSize = cmsGetProfileInfoASCII (cmyk_profile, cmsInfoDescription,
"en", "US", NULL, 0);
if (descSize > 0)
{
descData = g_new (gchar, descSize + 1);
descSize = cmsGetProfileInfoASCII (cmyk_profile, cmsInfoDescription,
"en", "US", descData, descSize);
if (descSize > 0)
{
name = descData;
}
else
{
g_free (descData);
descData = NULL;
}
}
if (name && ! g_utf8_validate (name, -1, NULL))
name = _("(invalid UTF-8 string)");
if (! name)
{
name = cmsTakeProductName (cmyk_profile);
descSize = cmsGetProfileInfoASCII (cmyk_profile, cmsInfoModel,
"en", "US", NULL, 0);
if (descSize > 0)
{
descData = g_new (gchar, descSize + 1);
descSize = cmsGetProfileInfoASCII (cmyk_profile, cmsInfoModel,
"en", "US", descData, descSize);
if (descSize > 0)
{
name = descData;
}
else
{
g_free (descData);
descData = NULL;
}
}
if (name && ! g_utf8_validate (name, -1, NULL))
name = _("(invalid UTF-8 string)");
}
@ -436,6 +470,9 @@ colorsel_cmyk_config_changed (ColorselCmyk *module)
gimp_help_set_help_data (module->name_label, text, NULL);
g_free (text);
if (descData)
g_free (descData);
rgb_profile = color_config_get_rgb_profile (config);
if (config->display_intent ==

View File

@ -19,13 +19,15 @@
#include <glib.h> /* lcms.h uses the "inline" keyword */
#include <string.h>
#ifdef G_OS_WIN32
#define STRICT
#include <windows.h>
#define LCMS_WIN_TYPES_ALREADY_DEFINED
#endif
#include <lcms.h>
#include <lcms2.h>
#include <gegl.h>
#include <gtk/gtk.h>
@ -36,6 +38,7 @@
#include <CoreServices/CoreServices.h>
#endif
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
#include "libgimpmath/gimpmath.h"
@ -134,8 +137,6 @@ cdisplay_lcms_class_init (CdisplayLcmsClass *klass)
display_class->configure = cdisplay_lcms_configure;
display_class->convert_surface = cdisplay_lcms_convert_surface;
display_class->changed = cdisplay_lcms_changed;
cmsErrorAction (LCMS_ERROR_IGNORE);
}
static void
@ -165,26 +166,71 @@ cdisplay_lcms_finalize (GObject *object)
static void
cdisplay_lcms_profile_get_info (cmsHPROFILE profile,
const gchar **name,
const gchar **info)
gchar **name,
gchar **info)
{
if (profile)
{
*name = cmsTakeProductDesc (profile);
cmsUInt32Number descSize;
gchar *descData;
descSize = cmsGetProfileInfoASCII (profile, cmsInfoDescription,
"en", "US", NULL, 0);
if (descSize > 0)
{
descData = g_new (gchar, descSize + 1);
descSize = cmsGetProfileInfoASCII (profile, cmsInfoDescription,
"en", "US", descData, descSize);
if (descSize > 0)
*name = descData;
else
g_free (descData);
}
if (! *name)
*name = cmsTakeProductName (profile);
{
descSize = cmsGetProfileInfoASCII (profile, cmsInfoModel,
"en", "US", NULL, 0);
if (descSize > 0)
{
descData = g_new (gchar, descSize + 1);
descSize = cmsGetProfileInfoASCII(profile, cmsInfoModel,
"en", "US", descData, descSize);
if (descSize > 0)
*name = descData;
else
g_free (descData);
}
}
if (*name && ! g_utf8_validate (*name, -1, NULL))
*name = _("(invalid UTF-8 string)");
{
g_free (*name);
*name = g_strdup (_("(invalid UTF-8 string)"));
}
*info = cmsTakeProductInfo (profile);
if (*name && ! g_utf8_validate (*info, -1, NULL))
*info = NULL;
descSize = cmsGetProfileInfoASCII (profile, cmsInfoManufacturer,
"en", "US", NULL, 0);
if (descSize > 0)
{
descData = g_new (gchar, descSize + 1);
descSize = cmsGetProfileInfoASCII (profile, cmsInfoManufacturer,
"en", "US", descData, descSize);
if (descSize > 0)
*info = descData;
else
g_free (descData);
}
if (*info && ! g_utf8_validate (*info, -1, NULL))
{
g_free (*info);
*info = NULL;
}
}
else
{
*name = _("None");
*name = g_strdup (_("None"));
*info = NULL;
}
}
@ -314,7 +360,8 @@ cdisplay_lcms_changed (GimpColorDisplay *display)
cmsHPROFILE src_profile = NULL;
cmsHPROFILE dest_profile = NULL;
cmsHPROFILE proof_profile = NULL;
DWORD flags = 0;
cmsUInt32Number flags = 0;
cmsUInt16Number alarmCodes[cmsMAXCHANNELS] = { 0 };
if (lcms->transform)
{
@ -364,7 +411,11 @@ cdisplay_lcms_changed (GimpColorDisplay *display)
gimp_rgb_get_uchar (&config->out_of_gamut_color, &r, &g, &b);
cmsSetAlarmCodes (r, g, b);
alarmCodes[0] = (cmsUInt16Number) r;
alarmCodes[1] = (cmsUInt16Number) g;
alarmCodes[2] = (cmsUInt16Number) b;
cmsSetAlarmCodes (alarmCodes);
}
lcms->transform = cmsCreateProofingTransform (src_profile, TYPE_ARGB_8,
@ -399,7 +450,7 @@ cdisplay_lcms_changed (GimpColorDisplay *display)
static gboolean
cdisplay_lcms_profile_is_rgb (cmsHPROFILE profile)
{
return (cmsGetColorSpace (profile) == icSigRgbData);
return (cmsGetColorSpace (profile) == cmsSigRgbData);
}
static cmsHPROFILE
@ -620,8 +671,8 @@ cdisplay_lcms_update_profile_label (CdisplayLcms *lcms,
{
GtkWidget *label;
cmsHPROFILE profile = NULL;
const gchar *text;
const gchar *tooltip;
gchar *text = NULL;
gchar *tooltip = NULL;
label = g_object_get_data (G_OBJECT (lcms), name);
@ -650,6 +701,9 @@ cdisplay_lcms_update_profile_label (CdisplayLcms *lcms,
gtk_label_set_text (GTK_LABEL (label), text);
gimp_help_set_help_data (label, tooltip, NULL);
g_free (text);
g_free (tooltip);
if (profile)
cmsCloseProfile (profile);
}

View File

@ -19,7 +19,7 @@
#include <glib.h> /* lcms.h uses the "inline" keyword */
#include <lcms.h>
#include <lcms2.h>
#include <gegl.h>
#include <gtk/gtk.h>
@ -146,8 +146,6 @@ cdisplay_proof_class_init (CdisplayProofClass *klass)
display_class->convert_surface = cdisplay_proof_convert_surface;
display_class->configure = cdisplay_proof_configure;
display_class->changed = cdisplay_proof_changed;
cmsErrorAction (LCMS_ERROR_IGNORE);
}
static void
@ -299,9 +297,37 @@ cdisplay_proof_combo_box_set_active (GimpColorProfileComboBox *combo,
if (profile)
{
label = gimp_any_to_utf8 (cmsTakeProductDesc (profile), -1, NULL);
cmsUInt32Number descSize;
gchar *descData;
descSize = cmsGetProfileInfoASCII(profile, cmsInfoDescription,
"en", "US", NULL, 0);
if (descSize > 0)
{
descData = g_new (gchar, descSize + 1);
descSize = cmsGetProfileInfoASCII (profile, cmsInfoDescription,
"en", "US", descData, descSize);
if (descSize > 0)
label = gimp_any_to_utf8 (descData, -1, NULL);
g_free (descData);
}
if (! label)
label = gimp_any_to_utf8 (cmsTakeProductName (profile), -1, NULL);
{
descSize = cmsGetProfileInfoASCII (profile, cmsInfoModel,
"en", "US", NULL, 0);
if (descSize > 0)
{
descData = g_new (gchar, descSize + 1);
descSize = cmsGetProfileInfoASCII (profile, cmsInfoModel,
"en", "US", descData, descSize);
if (descSize > 0)
label = gimp_any_to_utf8 (descData, -1, NULL);
g_free (descData);
}
}
cmsCloseProfile (profile);
}
@ -466,7 +492,7 @@ cdisplay_proof_changed (GimpColorDisplay *display)
if (proofProfile)
{
DWORD flags = cmsFLAGS_SOFTPROOFING;
cmsUInt32Number flags = cmsFLAGS_SOFTPROOFING;
if (proof->bpc)
flags |= cmsFLAGS_BLACKPOINTCOMPENSATION;

View File

@ -24,7 +24,7 @@
#include <glib.h> /* lcms.h uses the "inline" keyword */
#include <lcms.h>
#include <lcms2.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
@ -428,8 +428,6 @@ run (const gchar *name,
}
}
cmsErrorAction (LCMS_ERROR_SHOW);
switch (proc)
{
case PROC_SET:
@ -459,8 +457,6 @@ run (const gchar *name,
gchar *desc = NULL;
gchar *info = NULL;
cmsErrorAction (LCMS_ERROR_IGNORE);
if (proc == PROC_INFO)
status = lcms_icc_info (config, image, &name, &desc, &info);
else
@ -496,25 +492,76 @@ run (const gchar *name,
static gchar *
lcms_icc_profile_get_name (cmsHPROFILE profile)
{
return gimp_any_to_utf8 (cmsTakeProductName (profile), -1, NULL);
cmsUInt32Number descSize;
gchar *descData;
gchar *name = NULL;
descSize = cmsGetProfileInfoASCII (profile, cmsInfoModel,
"en", "US", NULL, 0);
if (descSize > 0)
{
descData = g_new (gchar, descSize + 1);
descSize = cmsGetProfileInfoASCII (profile, cmsInfoModel,
"en", "US", descData, descSize);
if (descSize > 0)
name = gimp_any_to_utf8 (descData, -1, NULL);
g_free (descData);
}
return name;
}
static gchar *
lcms_icc_profile_get_desc (cmsHPROFILE profile)
{
return gimp_any_to_utf8 (cmsTakeProductDesc (profile), -1, NULL);
cmsUInt32Number descSize;
gchar *descData;
gchar desc = NULL;
descSize = cmsGetProfileInfoASCII (profile, cmsInfoDescription,
"en", "US", NULL, 0);
if (descSize > 0)
{
descData = g_new (gchar, descSize + 1);
descSize = cmsGetProfileInfoASCII (profile, cmsInfoDescription,
"en", "US", descData, descSize);
if (descSize > 0)
desc = gimp_any_to_utf8 (descData, -1, NULL);
g_free (descData);
}
return desc;
}
static gchar *
lcms_icc_profile_get_info (cmsHPROFILE profile)
{
return gimp_any_to_utf8 (cmsTakeProductInfo (profile), -1, NULL);
cmsUInt32Number descSize;
gchar *descData;
gchar info = NULL;
descSize = cmsGetProfileInfoASCII (profile, cmsInfoModel,
"en", "US", NULL, 0);
if (descSize > 0)
{
descData = g_new (gchar, descSize + 1);
descSize = cmsGetProfileInfoASCII (profile, cmsInfoModel,
"en", "US", descData, descSize);
if (descSize > 0)
info = gimp_any_to_utf8 (descData, -1, NULL);
g_free (descData);
}
return info;
}
static gboolean
lcms_icc_profile_is_rgb (cmsHPROFILE profile)
{
return (cmsGetColorSpace (profile) == icSigRgbData);
return (cmsGetColorSpace (profile) == cmsSigRgbData);
}
static GimpPDBStatusType
@ -738,8 +785,8 @@ lcms_calculate_checksum (const gchar *data,
GChecksum *md5 = g_checksum_new (G_CHECKSUM_MD5);
g_checksum_update (md5,
(const guchar *) data + sizeof (icHeader),
len - sizeof (icHeader));
(const guchar *) data + sizeof (cmsICCHeader),
len - sizeof (cmsICCHeader));
len = 16;
g_checksum_get_digest (md5, digest, &len);
@ -934,18 +981,18 @@ lcms_image_transform_rgb (gint32 image,
GimpColorRenderingIntent intent,
gboolean bpc)
{
cmsHTRANSFORM transform = NULL;
DWORD last_format = 0;
gint *layers;
gint num_layers;
gint i;
cmsHTRANSFORM transform = NULL;
cmsUInt32Number last_format = 0;
gint *layers;
gint num_layers;
gint i;
layers = gimp_image_get_layers (image, &num_layers);
for (i = 0; i < num_layers; i++)
{
GimpDrawable *drawable = gimp_drawable_get (layers[i]);
DWORD format;
GimpDrawable *drawable = gimp_drawable_get (layers[i]);
cmsUInt32Number format;
switch (drawable->bpp)
{

View File

@ -31,7 +31,7 @@
#endif /* HAVE_LIBEXIF */
#ifdef HAVE_LCMS
#include <lcms.h>
#include <lcms2.h>
#endif
#include <libgimp/gimp.h>
@ -969,7 +969,7 @@ jpeg_load_cmyk_transform (guint8 *profile_data,
GimpColorConfig *config = gimp_get_color_configuration ();
cmsHPROFILE cmyk_profile = NULL;
cmsHPROFILE rgb_profile = NULL;
DWORD flags = 0;
cmsUInt32Number flags = 0;
cmsHTRANSFORM transform;
/* try to load the embedded CMYK profile */
@ -979,7 +979,7 @@ jpeg_load_cmyk_transform (guint8 *profile_data,
if (cmyk_profile)
{
if (! cmsGetColorSpace (cmyk_profile) == icSigCmykData)
if (! cmsGetColorSpace (cmyk_profile) == cmsSigCmykData)
{
cmsCloseProfile (cmyk_profile);
cmyk_profile = NULL;
@ -992,7 +992,7 @@ jpeg_load_cmyk_transform (guint8 *profile_data,
{
cmyk_profile = cmsOpenProfileFromFile (config->cmyk_profile, "r");
if (cmyk_profile && ! cmsGetColorSpace (cmyk_profile) == icSigCmykData)
if (cmyk_profile && ! cmsGetColorSpace (cmyk_profile) == cmsSigCmykData)
{
cmsCloseProfile (cmyk_profile);
cmyk_profile = NULL;
@ -1011,7 +1011,7 @@ jpeg_load_cmyk_transform (guint8 *profile_data,
{
rgb_profile = cmsOpenProfileFromFile (config->rgb_profile, "r");
if (rgb_profile && ! cmsGetColorSpace (rgb_profile) == icSigRgbData)
if (rgb_profile && ! cmsGetColorSpace (rgb_profile) == cmsSigRgbData)
{
cmsCloseProfile (rgb_profile);
rgb_profile = NULL;