mirror of
https://gitlab.gnome.org/GNOME/eog
synced 2024-10-18 14:04:27 +00:00
More patches from Ross Burton improving the ICC profile support and make linking against -llcms optional.
This commit is contained in:
parent
d66242aa15
commit
108e01fecd
|
@ -1,3 +1,8 @@
|
|||
2005-07-13 Tim Gerla <tim@gerla.net>
|
||||
|
||||
* More patches from Ross Burton improving the ICC profile support
|
||||
and make linking against -llcms optional.
|
||||
|
||||
2005-07-11 Tim Gerla <tim@gerla.net>
|
||||
|
||||
* Apply patches from Ross Burton <ross@burtonini.com> to add ICC
|
||||
|
|
133
INSTALL
133
INSTALL
|
@ -1,3 +1,9 @@
|
|||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
|
@ -8,20 +14,27 @@ various system-dependent variables used during compilation. It uses
|
|||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, a file
|
||||
`config.cache' that saves the results of its tests to speed up
|
||||
reconfiguring, and a file `config.log' containing compiler output
|
||||
(useful mainly for debugging `configure').
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. (Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.)
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If at some point `config.cache'
|
||||
contains results you don't want to keep, you may remove or edit it.
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.in' is used to create `configure' by a program
|
||||
called `autoconf'. You only need `configure.in' if you want to change
|
||||
it or regenerate `configure' using a newer version of `autoconf'.
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You only need
|
||||
`configure.ac' if you want to change it or regenerate `configure' using
|
||||
a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
|
@ -55,14 +68,16 @@ Compilers and Options
|
|||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. You can give `configure'
|
||||
initial values for variables by setting them in the environment. Using
|
||||
a Bourne-compatible shell, you can do that on the command line like
|
||||
this:
|
||||
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
|
||||
the `configure' script does not know about. Run `./configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
Or on systems that have the `env' program, you can do it like this:
|
||||
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
@ -75,11 +90,11 @@ directory where you want the object files and executables to go and run
|
|||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not supports the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a time
|
||||
in the source code directory. After you have installed the package for
|
||||
one architecture, use `make distclean' before reconfiguring for another
|
||||
architecture.
|
||||
If you have to use a `make' that does not support the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a
|
||||
time in the source code directory. After you have installed the
|
||||
package for one architecture, use `make distclean' before reconfiguring
|
||||
for another architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
@ -122,22 +137,32 @@ you can use the `configure' options `--x-includes=DIR' and
|
|||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' can not figure out
|
||||
automatically, but needs to determine by the type of host the package
|
||||
will run on. Usually `configure' can figure that out, but if it prints
|
||||
a message saying it can not guess the host type, give it the
|
||||
`--host=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name with three fields:
|
||||
There may be some features `configure' cannot figure out
|
||||
automatically, but needs to determine by the type of machine the package
|
||||
will run on. Usually, assuming the package is built to be run on the
|
||||
_same_ architectures, `configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the host type.
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
If you are building compiler tools for cross-compiling, you can also
|
||||
OS KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the `--target=TYPE' option to select the type of system they will
|
||||
produce code for and the `--build=TYPE' option to select the type of
|
||||
system on which you are compiling the package.
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
@ -150,20 +175,44 @@ default values for variables like `CC', `cache_file', and `prefix'.
|
|||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Operation Controls
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
will cause the specified gcc to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Use and save the results of the tests in FILE instead of
|
||||
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
|
||||
debugging `configure'.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
|
@ -175,8 +224,6 @@ operates.
|
|||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`--version'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options.
|
||||
|
|
24
configure.in
24
configure.in
|
@ -65,6 +65,19 @@ if test "x$have_exif" = "xyes"; then
|
|||
EOG_MODULES="$EOG_MODULES libexif >= $LIBEXIF_REQUIRED"
|
||||
fi
|
||||
|
||||
dnl ============== optional Little CMS support ====================
|
||||
|
||||
AC_ARG_WITH(cms, [ --without-cms disable colour management support])
|
||||
have_lcms=no
|
||||
if test x$with_cms != xno; then
|
||||
PKG_CHECK_MODULES(LCMS, lcms, have_lcms=yes, have_lcms=no)
|
||||
fi
|
||||
if test "x$have_lcms" = "xyes"; then
|
||||
AC_DEFINE(HAVE_LCMS,1,[Little CMS library is present])
|
||||
EOG_MODULES="$EOG_MODULES lcms"
|
||||
fi
|
||||
AM_CONDITIONAL(ENABLE_LCMS, test x$have_lcms = xyes)
|
||||
|
||||
dnl ============== semi optional libjpeg support ====================
|
||||
AC_ARG_WITH(libjpeg, [ --without-libjpeg disable special JPEG support])
|
||||
have_jpeg=no
|
||||
|
@ -199,10 +212,11 @@ po/Makefile.in
|
|||
echo "
|
||||
Configuration:
|
||||
|
||||
Source code location: ${srcdir}
|
||||
Compiler: ${CC}
|
||||
Source code location: ${srcdir}
|
||||
Compiler: ${CC}
|
||||
|
||||
Extra Compiler Warnings: ${WARN_CFLAGS}
|
||||
Special EXIF support: ${have_exif}
|
||||
Special JPEG support: ${have_jpeg}
|
||||
Extra Compiler Warnings: ${WARN_CFLAGS}
|
||||
Special EXIF support: ${have_exif}
|
||||
Special JPEG support: ${have_jpeg}
|
||||
Colour management support: ${have_lcms}
|
||||
"
|
||||
|
|
|
@ -115,7 +115,8 @@ test_eog_job_LDADD = \
|
|||
$(jpeg_LIB) \
|
||||
$(X_LIBS) \
|
||||
$(EOG_LIBS) \
|
||||
$(LIBJPEG) -llcms
|
||||
$(LIBJPEG)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -129,7 +130,7 @@ test_image_load_LDADD = \
|
|||
$(jpeg_LIB) \
|
||||
$(X_LIBS) \
|
||||
$(EOG_LIBS) \
|
||||
$(LIBJPEG) -llcms
|
||||
$(LIBJPEG)
|
||||
|
||||
CLEANFILES = $(BUILT_SOURCES)
|
||||
|
||||
|
|
|
@ -26,7 +26,12 @@
|
|||
#include "eog-image-jpeg.h"
|
||||
#endif
|
||||
|
||||
#include <lcms.h>
|
||||
#if HAVE_LCMS
|
||||
#include <lcms.h>
|
||||
#ifndef EXIF_TAG_GAMMA
|
||||
#define EXIF_TAG_GAMMA 0xa500
|
||||
#endif
|
||||
#endif
|
||||
|
||||
enum {
|
||||
SIGNAL_LOADING_UPDATE,
|
||||
|
@ -254,7 +259,9 @@ eog_image_instance_init (EogImage *img)
|
|||
#if HAVE_EXIF
|
||||
priv->exif = NULL;
|
||||
#endif
|
||||
#if HAVE_LCMS
|
||||
priv->profile = NULL;
|
||||
#endif
|
||||
priv->data_ref_count = 0;
|
||||
|
||||
img->priv = priv;
|
||||
|
@ -552,6 +559,7 @@ eog_image_load_exif_data_only (EogImage *img, EogJob *job, GError **error)
|
|||
return !failed;
|
||||
}
|
||||
|
||||
#if HAVE_LCMS
|
||||
void
|
||||
eog_image_apply_display_profile (EogImage *img, cmsHPROFILE screen)
|
||||
{
|
||||
|
@ -584,7 +592,7 @@ eog_image_apply_display_profile (EogImage *img, cmsHPROFILE screen)
|
|||
}
|
||||
|
||||
static void
|
||||
extract_profile (EogImage *img)
|
||||
extract_profile (EogImage *img, EogMetadataReader *md_reader)
|
||||
{
|
||||
EogImagePrivate *priv = img->priv;
|
||||
ExifEntry *entry;
|
||||
|
@ -592,12 +600,34 @@ extract_profile (EogImage *img)
|
|||
|
||||
/* TODO: switch on format to specialised functions */
|
||||
|
||||
/* No EXIF data, so can't do anything for now. Should check for embedded ICC profile. */
|
||||
/* Embedded ICC profiles rule over anything else */
|
||||
{
|
||||
gpointer data = eog_metadata_reader_get_icc_chunk (md_reader);
|
||||
if (data != NULL) {
|
||||
priv->profile = cmsOpenProfileFromMem(data, eog_metadata_reader_get_icc_chunk_size (md_reader));
|
||||
g_assert (priv->profile != NULL);
|
||||
g_printerr("JPEG has ICC profile\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* No EXIF data, so can't do anything */
|
||||
if (priv->exif == NULL)
|
||||
return;
|
||||
|
||||
entry = exif_content_get_entry (priv->exif->ifd [EXIF_IFD_EXIF], EXIF_TAG_COLOR_SPACE);
|
||||
if (entry && exif_get_short (entry->data, o) != 1) {
|
||||
if (entry == NULL)
|
||||
return;
|
||||
|
||||
if (exif_get_short (entry->data, o) == 1) {
|
||||
priv->profile = cmsCreate_sRGBProfile ();
|
||||
g_printerr ("JPEG is sRGB\n");
|
||||
} else if (exif_get_short (entry->data, o) == 2) {
|
||||
/* TODO: create Adobe RGB profile */
|
||||
//priv->profile = cmsCreate_Adobe1998Profile ();
|
||||
g_printerr ("JPEG is Adobe RGB (NOT correcting for now!)\n");
|
||||
} else if (exif_get_short (entry->data, o) == 0xFFFF) {
|
||||
double gammaValue;
|
||||
cmsCIExyY whitepoint;
|
||||
cmsCIExyYTRIPLE primaries;
|
||||
LPGAMMATABLE gamma[3];
|
||||
|
@ -614,6 +644,7 @@ extract_profile (EogImage *img)
|
|||
whitepoint.Y = 1.0;
|
||||
} else {
|
||||
g_printerr("No whitepoint found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
entry = exif_content_get_entry (priv->exif->ifd [EXIF_IFD_0], EXIF_TAG_PRIMARY_CHROMATICITIES);
|
||||
|
@ -636,15 +667,27 @@ extract_profile (EogImage *img)
|
|||
primaries.Red.Y = primaries.Green.Y = primaries.Blue.Y = 1.0;
|
||||
} else {
|
||||
g_printerr("No primary chromaticities found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
entry = exif_content_get_entry (priv->exif->ifd [EXIF_IFD_EXIF], EXIF_TAG_GAMMA);
|
||||
if (entry) {
|
||||
r = exif_get_rational (entry->data, o);
|
||||
gammaValue = (double)r.numerator/r.denominator;
|
||||
} else {
|
||||
/* Assume 2.2 */
|
||||
g_printerr("No gamma found\n");
|
||||
gammaValue = 2.2;
|
||||
}
|
||||
|
||||
/* TODO: assume gamma 2.2? */
|
||||
gamma[0] = gamma[1] = gamma[2] = cmsBuildGamma(256, 2.2);
|
||||
gamma[0] = gamma[1] = gamma[2] = cmsBuildGamma(256, gammaValue);
|
||||
|
||||
priv->profile = cmsCreateRGBProfile(&whitepoint, &primaries, gamma);
|
||||
g_printerr ("JPEG is calibrated\n");
|
||||
cmsFreeGamma(gamma[0]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* this function runs in it's own thread */
|
||||
static gboolean
|
||||
|
@ -776,8 +819,9 @@ eog_image_real_load (EogImage *img, guint data2read, EogJob *job, GError **error
|
|||
if (format != NULL) {
|
||||
priv->file_type = gdk_pixbuf_format_get_name (format);
|
||||
}
|
||||
|
||||
extract_profile (img);
|
||||
#if HAVE_LCMS
|
||||
extract_profile (img, md_reader);
|
||||
#endif
|
||||
}
|
||||
/* clean up */
|
||||
g_object_unref (loader);
|
||||
|
@ -942,6 +986,7 @@ eog_image_get_pixbuf (EogImage *img)
|
|||
return image;
|
||||
}
|
||||
|
||||
#if HAVE_LCMS
|
||||
cmsHPROFILE
|
||||
eog_image_get_profile (EogImage *img)
|
||||
{
|
||||
|
@ -949,7 +994,7 @@ eog_image_get_profile (EogImage *img)
|
|||
|
||||
return img->priv->profile;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
GdkPixbuf*
|
||||
eog_image_get_pixbuf_thumbnail (EogImage *img)
|
||||
|
@ -1572,9 +1617,11 @@ eog_image_free_mem_private (EogImage *image)
|
|||
}
|
||||
priv->exif_chunk_len = 0;
|
||||
|
||||
#if HAVE_LCMS
|
||||
if (priv->profile != NULL) {
|
||||
cmsCloseProfile (priv->profile);
|
||||
}
|
||||
#endif
|
||||
|
||||
priv->status = EOG_IMAGE_STATUS_UNKNOWN;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ typedef enum {
|
|||
EMR_READ_MARKER,
|
||||
EMR_SKIP_BYTES,
|
||||
EMR_READ_EXIF,
|
||||
EMR_READ_ICC,
|
||||
EMR_READ_IPTC,
|
||||
EMR_FINISHED
|
||||
} EogMetadataReaderState;
|
||||
|
@ -21,6 +22,7 @@ typedef enum {
|
|||
#define EOG_JPEG_MARKER_START 0xFF
|
||||
#define EOG_JPEG_MARKER_SOI 0xD8
|
||||
#define EOG_JPEG_MARKER_APP1 0xE1
|
||||
#define EOG_JPEG_MARKER_APP2 0xE2
|
||||
#define EOG_JPEG_MARKER_APP14 0xED
|
||||
|
||||
#define NO_DEBUG
|
||||
|
@ -35,6 +37,9 @@ struct _EogMetadataReaderPrivate {
|
|||
gpointer iptc_chunk;
|
||||
guint iptc_len;
|
||||
|
||||
gpointer icc_chunk;
|
||||
guint icc_len;
|
||||
|
||||
/* management fields */
|
||||
int size;
|
||||
int last_marker;
|
||||
|
@ -64,6 +69,11 @@ eog_metadata_reader_dispose (GObject *object)
|
|||
g_free (emr->priv->iptc_chunk);
|
||||
emr->priv->iptc_chunk = NULL;
|
||||
}
|
||||
|
||||
if (emr->priv->icc_chunk != NULL) {
|
||||
g_free (emr->priv->icc_chunk);
|
||||
emr->priv->icc_chunk = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -76,6 +86,8 @@ eog_metadata_reader_instance_init (EogMetadataReader *obj)
|
|||
priv->exif_len = 0;
|
||||
priv->iptc_chunk = NULL;
|
||||
priv->iptc_len = 0;
|
||||
priv->icc_chunk = NULL;
|
||||
priv->icc_len = 0;
|
||||
|
||||
obj->priv = priv;
|
||||
}
|
||||
|
@ -173,6 +185,11 @@ eog_metadata_reader_consume (EogMetadataReader *emr, guchar *buf, guint len)
|
|||
{
|
||||
priv->state = EMR_READ_EXIF;
|
||||
}
|
||||
else if (priv->last_marker == EOG_JPEG_MARKER_APP2 &&
|
||||
priv->icc_chunk == NULL)
|
||||
{
|
||||
priv->state = EMR_READ_ICC;
|
||||
}
|
||||
else if (priv->last_marker == EOG_JPEG_MARKER_APP14 &&
|
||||
priv->iptc_chunk == NULL)
|
||||
{
|
||||
|
@ -227,7 +244,36 @@ eog_metadata_reader_consume (EogMetadataReader *emr, guchar *buf, guint len)
|
|||
priv->state = EMR_READ_EXIF;
|
||||
}
|
||||
|
||||
if (priv->exif_chunk != NULL && priv->iptc_chunk != NULL)
|
||||
if (priv->exif_chunk != NULL && priv->icc_chunk != NULL && priv->iptc_chunk != NULL)
|
||||
priv->state = EMR_FINISHED;
|
||||
break;
|
||||
|
||||
case EMR_READ_ICC:
|
||||
#ifdef DEBUG
|
||||
g_print ("Read ICC data, length: %i\n", priv->size);
|
||||
#endif
|
||||
if (priv->icc_chunk == NULL) {
|
||||
priv->icc_chunk = g_new0 (guchar, priv->size);
|
||||
priv->icc_len = priv->size;
|
||||
priv->bytes_read = 0;
|
||||
}
|
||||
|
||||
if (i + priv->size < len) {
|
||||
/* read data in one block */
|
||||
memcpy ((void*) ((int)(priv->icc_chunk) + priv->bytes_read), (void*)&buf[i], priv->size);
|
||||
priv->state = EMR_READ;
|
||||
i = i + priv->size - 1; /* the for-loop consumes the other byte */
|
||||
}
|
||||
else {
|
||||
int chunk_len = len - i;
|
||||
memcpy ((void*)((int)priv->icc_chunk + priv->bytes_read), (void*)&buf[i], chunk_len);
|
||||
priv->bytes_read += chunk_len; /* bytes already read */
|
||||
priv->size = (i + priv->size) - len; /* remaining data to read */
|
||||
i = len - 1;
|
||||
priv->state = EMR_READ_ICC;
|
||||
}
|
||||
|
||||
if (priv->exif_chunk != NULL && priv->icc_chunk != NULL && priv->iptc_chunk != NULL)
|
||||
priv->state = EMR_FINISHED;
|
||||
break;
|
||||
|
||||
|
@ -252,7 +298,7 @@ eog_metadata_reader_consume (EogMetadataReader *emr, guchar *buf, guint len)
|
|||
priv->state = EMR_READ_IPTC;
|
||||
}
|
||||
|
||||
if (priv->exif_chunk != NULL && priv->iptc_chunk != NULL)
|
||||
if (priv->exif_chunk != NULL && priv->icc_chunk != NULL && priv->iptc_chunk != NULL)
|
||||
priv->state = EMR_FINISHED;
|
||||
break;
|
||||
|
||||
|
@ -297,3 +343,26 @@ eog_metadata_reader_get_exif_data (EogMetadataReader *emr)
|
|||
return data;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* TODO: very broken, assumes the profile fits in a single chunk. Change to
|
||||
* parse the sections and construct a single memory chunk, or maybe even parse
|
||||
* the profile.
|
||||
*/
|
||||
|
||||
gpointer
|
||||
eog_metadata_reader_get_icc_chunk (EogMetadataReader *emr)
|
||||
{
|
||||
g_return_val_if_fail (EOG_IS_METADATA_READER (emr), NULL);
|
||||
if (emr->priv->icc_chunk)
|
||||
return emr->priv->icc_chunk + 14;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
guint
|
||||
eog_metadata_reader_get_icc_chunk_size (EogMetadataReader *emr)
|
||||
{
|
||||
g_return_val_if_fail (EOG_IS_METADATA_READER (emr), -1);
|
||||
return emr->priv->icc_len - 14;
|
||||
}
|
||||
|
|
|
@ -49,6 +49,9 @@ gpointer eog_metadata_reader_get_iptc_chunk (EogMetadataReader *emr)
|
|||
IptcData* eog_metadata_reader_get_iptc_data (EogMetadataReader *emr);
|
||||
#endif
|
||||
|
||||
gpointer eog_metadata_reader_get_icc_chunk (EogMetadataReader *emr);
|
||||
guint eog_metadata_reader_get_icc_chunk_size (EogMetadataReader *emr);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _EOG_METADATA_READER_H_ */
|
||||
|
|
|
@ -7,11 +7,6 @@
|
|||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <lcms.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
#include "libeog-marshal.h"
|
||||
#include "eog-scroll-view.h"
|
||||
#include "cursors.h"
|
||||
|
@ -1729,38 +1724,6 @@ eog_scroll_view_get_zoom_is_max (EogScrollView *view)
|
|||
return DOUBLE_EQUAL (view->priv->zoom, MAX_ZOOM_FACTOR);
|
||||
}
|
||||
|
||||
static cmsHPROFILE *
|
||||
get_screen_profile (GdkScreen *screen)
|
||||
{
|
||||
Display *dpy;
|
||||
Atom icc_atom, type;
|
||||
int format;
|
||||
gulong nitems;
|
||||
gulong bytes_after;
|
||||
guchar *str;
|
||||
int result;
|
||||
cmsHPROFILE *profile;
|
||||
|
||||
g_return_val_if_fail (screen != NULL, NULL);
|
||||
|
||||
dpy = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
|
||||
icc_atom = gdk_x11_get_xatom_by_name_for_display (gdk_screen_get_display (screen), "_ICC_PROFILE");
|
||||
|
||||
result = XGetWindowProperty (dpy, GDK_WINDOW_XID (gdk_screen_get_root_window (screen)),
|
||||
icc_atom, 0, G_MAXLONG,
|
||||
False, XA_CARDINAL, &type, &format, &nitems,
|
||||
&bytes_after, (guchar **)&str);
|
||||
|
||||
if (nitems) {
|
||||
profile = cmsOpenProfileFromMem(str, nitems * sizeof(long));
|
||||
XFree (str);
|
||||
return profile;
|
||||
} else {
|
||||
g_printerr("No profile, not correcting\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
eog_scroll_view_set_image (EogScrollView *view, EogImage *image)
|
||||
{
|
||||
|
@ -1788,8 +1751,6 @@ eog_scroll_view_set_image (EogScrollView *view, EogImage *image)
|
|||
eog_image_data_ref (image);
|
||||
|
||||
if (priv->pixbuf == NULL) {
|
||||
/* TODO: do this in a thread, progressively */
|
||||
eog_image_apply_display_profile (image, get_screen_profile (gtk_widget_get_screen (GTK_WIDGET (view))));
|
||||
priv->pixbuf = eog_image_get_pixbuf (image);
|
||||
priv->progressive_state = PROGRESSIVE_NONE;
|
||||
set_zoom_fit (view);
|
||||
|
|
|
@ -47,7 +47,7 @@ eog_LDADD = \
|
|||
$(POPT_LIBS) \
|
||||
$(X_LIBS) \
|
||||
$(EOG_LIBS) \
|
||||
$(LIBJPEG) -llcms
|
||||
$(LIBJPEG)
|
||||
|
||||
uidir = $(datadir)/eog
|
||||
UI_FILES = eog-gtk-ui.xml
|
||||
|
|
|
@ -60,6 +60,10 @@
|
|||
#include "eog-pixbuf-util.h"
|
||||
#include "eog-job-manager.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <lcms.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
||||
#define getgid() 0
|
||||
|
@ -2750,6 +2754,44 @@ show_error_dialog (EogWindow *window, char *header, GError *error)
|
|||
gtk_widget_show_all (dlg);
|
||||
}
|
||||
|
||||
#if HAVE_LCMS
|
||||
/* TODO: move into library */
|
||||
static cmsHPROFILE *
|
||||
get_screen_profile (EogWindow *window)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
Display *dpy;
|
||||
Atom icc_atom, type;
|
||||
int format;
|
||||
gulong nitems;
|
||||
gulong bytes_after;
|
||||
guchar *str;
|
||||
int result;
|
||||
cmsHPROFILE *profile;
|
||||
|
||||
g_return_val_if_fail (window != NULL, NULL);
|
||||
|
||||
screen = gtk_widget_get_screen (GTK_WIDGET (window));
|
||||
dpy = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
|
||||
icc_atom = gdk_x11_get_xatom_by_name_for_display (gdk_screen_get_display (screen), "_ICC_PROFILE");
|
||||
|
||||
result = XGetWindowProperty (dpy, GDK_WINDOW_XID (gdk_screen_get_root_window (screen)),
|
||||
icc_atom, 0, G_MAXLONG,
|
||||
False, XA_CARDINAL, &type, &format, &nitems,
|
||||
&bytes_after, (guchar **)&str);
|
||||
/* TODO: handle bytes_after != 0 */
|
||||
|
||||
if (nitems) {
|
||||
profile = cmsOpenProfileFromMem(str, nitems);
|
||||
XFree (str);
|
||||
return profile;
|
||||
} else {
|
||||
g_printerr("No profile, not correcting\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
display_image_data (EogWindow *window, EogImage *image)
|
||||
{
|
||||
|
@ -2809,6 +2851,9 @@ job_image_load_finished (EogJob *job, gpointer data, GError *error)
|
|||
if (eog_job_get_status (job) == EOG_JOB_STATUS_FINISHED) {
|
||||
if (eog_job_get_success (job)) {
|
||||
/* successfull */
|
||||
#if HAVE_LCMS
|
||||
eog_image_apply_display_profile (image, get_screen_profile (window));
|
||||
#endif
|
||||
display_image_data (window, image);
|
||||
}
|
||||
else { /* failed */
|
||||
|
@ -3488,6 +3533,7 @@ gboolean
|
|||
eog_window_open (EogWindow *window, EogImageList *model, GError **error)
|
||||
{
|
||||
EogWindowPrivate *priv;
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (EOG_IS_WINDOW (window), FALSE);
|
||||
|
||||
|
@ -3497,6 +3543,13 @@ eog_window_open (EogWindow *window, EogImageList *model, GError **error)
|
|||
g_print ("EogWindow.c: eog_window_open\n");
|
||||
#endif
|
||||
|
||||
#if HAVE_LCMS
|
||||
/* Colour-correct the images */
|
||||
for (i = 0; i < eog_image_list_length (model); i++) {
|
||||
eog_image_apply_display_profile (eog_image_list_get_img_by_pos (model, i), get_screen_profile (window));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* attach image list */
|
||||
if (priv->image_list != NULL) {
|
||||
g_signal_handler_disconnect (G_OBJECT (priv->image_list), priv->sig_id_list_prepared);
|
||||
|
|
Loading…
Reference in a new issue