app: add a per-image "is color managed" switch

in order to enable/disable color management for this image. Completely
unused at the moment.
This commit is contained in:
Michael Natterer 2016-05-08 18:02:57 +02:00
parent 1dc9deb309
commit 81845552ef
10 changed files with 74 additions and 0 deletions

View File

@ -824,6 +824,7 @@ gimp_undo_type_get_type (void)
{ GIMP_UNDO_IMAGE_GRID, "GIMP_UNDO_IMAGE_GRID", "image-grid" },
{ GIMP_UNDO_IMAGE_METADATA, "GIMP_UNDO_IMAGE_METADATA", "image-metadata" },
{ GIMP_UNDO_IMAGE_COLORMAP, "GIMP_UNDO_IMAGE_COLORMAP", "image-colormap" },
{ GIMP_UNDO_IMAGE_COLOR_MANAGED, "GIMP_UNDO_IMAGE_COLOR_MANAGED", "image-color-managed" },
{ GIMP_UNDO_GUIDE, "GIMP_UNDO_GUIDE", "guide" },
{ GIMP_UNDO_SAMPLE_POINT, "GIMP_UNDO_SAMPLE_POINT", "sample-point" },
{ GIMP_UNDO_DRAWABLE, "GIMP_UNDO_DRAWABLE", "drawable" },
@ -915,6 +916,7 @@ gimp_undo_type_get_type (void)
{ GIMP_UNDO_IMAGE_GRID, NC_("undo-type", "Grid"), NULL },
{ GIMP_UNDO_IMAGE_METADATA, NC_("undo-type", "Change metadata"), NULL },
{ GIMP_UNDO_IMAGE_COLORMAP, NC_("undo-type", "Change indexed palette"), NULL },
{ GIMP_UNDO_IMAGE_COLOR_MANAGED, NC_("undo-type", "Change color managed state"), NULL },
{ GIMP_UNDO_GUIDE, NC_("undo-type", "Guide"), NULL },
{ GIMP_UNDO_SAMPLE_POINT, NC_("undo-type", "Sample Point"), NULL },
{ GIMP_UNDO_DRAWABLE, NC_("undo-type", "Layer/Channel"), NULL },

View File

@ -415,6 +415,7 @@ typedef enum /*< pdb-skip >*/
GIMP_UNDO_IMAGE_GRID, /*< desc="Grid" >*/
GIMP_UNDO_IMAGE_METADATA, /*< desc="Change metadata" >*/
GIMP_UNDO_IMAGE_COLORMAP, /*< desc="Change indexed palette" >*/
GIMP_UNDO_IMAGE_COLOR_MANAGED, /*< desc="Change color managed state" >*/
GIMP_UNDO_GUIDE, /*< desc="Guide" >*/
GIMP_UNDO_SAMPLE_POINT, /*< desc="Sample Point" >*/
GIMP_UNDO_DRAWABLE, /*< desc="Layer/Channel" >*/

View File

@ -47,6 +47,7 @@
#include "gimpimage-colormap.h"
#include "gimpimage-private.h"
#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
#include "gimpprogress.h"
#include "gimpsubprogress.h"
@ -71,6 +72,38 @@ static void gimp_image_convert_profile_colormap (GimpImage *ima
/* public functions */
gboolean
gimp_image_get_is_color_managed (GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
return GIMP_IMAGE_GET_PRIVATE (image)->is_color_managed;
}
void
gimp_image_set_is_color_managed (GimpImage *image,
gboolean is_color_managed,
gboolean push_undo)
{
GimpImagePrivate *private;
g_return_if_fail (GIMP_IS_IMAGE (image));
private = GIMP_IMAGE_GET_PRIVATE (image);
is_color_managed = is_color_managed ? TRUE : FALSE;
if (is_color_managed != private->is_color_managed)
{
if (push_undo)
gimp_image_undo_push_image_color_managed (image, NULL);
private->is_color_managed = is_color_managed;
gimp_color_managed_profile_changed (GIMP_COLOR_MANAGED (image));
}
}
gboolean
gimp_image_validate_icc_parasite (GimpImage *image,
const GimpParasite *icc_parasite,

View File

@ -25,6 +25,11 @@
#define GIMP_ICC_PROFILE_PARASITE_NAME "icc-profile"
gboolean gimp_image_get_is_color_managed (GimpImage *image);
void gimp_image_set_is_color_managed (GimpImage *image,
gboolean is_color_managed,
gboolean push_undo);
gboolean gimp_image_validate_icc_parasite (GimpImage *image,
const GimpParasite *icc_parasite,
gboolean *is_builtin,

View File

@ -56,6 +56,7 @@ struct _GimpImagePrivate
const Babl *babl_palette_rgb; /* palette's RGB Babl format */
const Babl *babl_palette_rgba; /* palette's RGBA Babl format */
gboolean is_color_managed; /* is this image color managed */
GimpColorProfile *color_profile; /* image's color profile */
/* Cached color transforms: from layer to sRGB u8 and double, and back */

View File

@ -148,6 +148,18 @@ gimp_image_undo_push_image_colormap (GimpImage *image,
NULL);
}
GimpUndo *
gimp_image_undo_push_image_color_managed (GimpImage *image,
const gchar *undo_desc)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
return gimp_image_undo_push (image, GIMP_TYPE_IMAGE_UNDO,
GIMP_UNDO_IMAGE_COLOR_MANAGED, undo_desc,
GIMP_DIRTY_IMAGE,
NULL);
}
GimpUndo *
gimp_image_undo_push_image_metadata (GimpImage *image,
const gchar *undo_desc)

View File

@ -38,6 +38,8 @@ GimpUndo * gimp_image_undo_push_image_grid (GimpImage *image,
GimpGrid *grid);
GimpUndo * gimp_image_undo_push_image_colormap (GimpImage *image,
const gchar *undo_desc);
GimpUndo * gimp_image_undo_push_image_color_managed (GimpImage *image,
const gchar *undo_desc);
GimpUndo * gimp_image_undo_push_image_metadata (GimpImage *image,
const gchar *undo_desc);
GimpUndo * gimp_image_undo_push_image_parasite (GimpImage *image,

View File

@ -692,6 +692,8 @@ gimp_image_init (GimpImage *image)
private->n_colors = 0;
private->palette = NULL;
private->is_color_managed = TRUE;
private->metadata = NULL;
private->dirty = 1;

View File

@ -188,6 +188,10 @@ gimp_image_undo_constructed (GObject *object)
GIMP_IMAGE_COLORMAP_SIZE);
break;
case GIMP_UNDO_IMAGE_COLOR_MANAGED:
image_undo->is_color_managed = gimp_image_get_is_color_managed (image);
break;
case GIMP_UNDO_IMAGE_METADATA:
image_undo->metadata =
gimp_metadata_duplicate (gimp_image_get_metadata (image));
@ -468,6 +472,17 @@ gimp_image_undo_pop (GimpUndo *undo,
}
break;
case GIMP_UNDO_IMAGE_COLOR_MANAGED:
{
gboolean is_color_managed;
is_color_managed = gimp_image_get_is_color_managed (image);
gimp_image_set_is_color_managed (image, image_undo->is_color_managed,
FALSE);
image_undo->is_color_managed = is_color_managed;
}
break;
case GIMP_UNDO_IMAGE_METADATA:
{
GimpMetadata *metadata;

View File

@ -50,6 +50,7 @@ struct _GimpImageUndo
GimpGrid *grid;
gint num_colors;
guchar *colormap;
gboolean is_color_managed;
GimpMetadata *metadata;
gchar *parasite_name;
GimpParasite *parasite;