[gimp/alxsa-save-intent-bpc-xcf] app: Save simulation intent and bpc in XCF file
- From: Alx Sa <sawyeralex src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/alxsa-save-intent-bpc-xcf] app: Save simulation intent and bpc in XCF file
- Date: Thu, 18 Aug 2022 22:30:05 +0000 (UTC)
commit 32d7d102c9230d7a776f496953322590b8a49636
Author: Alx Sa <cmyk student gmail com>
Date: Thu Aug 18 22:30:04 2022 +0000
app: Save simulation intent and bpc in XCF file
Creates two new parasites to save the black point compensation status
and rendering intent simulation settings in GimpImage.
The parasites are saved and loaded as part of the image in the
.xcf file.
app/core/gimpimage-color-profile.c | 22 +++++++++++
app/xcf/xcf-load.c | 75 ++++++++++++++++++++++++++++++++++++++
2 files changed, 97 insertions(+)
---
diff --git a/app/core/gimpimage-color-profile.c b/app/core/gimpimage-color-profile.c
index 9bd1f8f22f..c7acd6d1be 100644
--- a/app/core/gimpimage-color-profile.c
+++ b/app/core/gimpimage-color-profile.c
@@ -477,8 +477,19 @@ gimp_image_set_simulation_intent (GimpImage *image,
if (intent != private->simulation_intent)
{
+ GimpParasite *parasite;
+ gchar *str;
+
private->simulation_intent = intent;
gimp_color_managed_simulation_intent_changed (GIMP_COLOR_MANAGED (image));
+
+ str = g_strdup_printf ("%d", intent);
+ parasite = gimp_parasite_new ("image-simulation-intent",
+ GIMP_PARASITE_PERSISTENT,
+ strlen (str) + 1, (gpointer) str);
+ g_free (str);
+ gimp_image_parasite_attach (image, parasite, FALSE);
+ gimp_parasite_free (parasite);
}
}
@@ -502,8 +513,19 @@ gimp_image_set_simulation_bpc (GimpImage *image,
if (bpc != private->simulation_bpc)
{
+ GimpParasite *parasite;
+ gchar *str;
+
private->simulation_bpc = bpc;
gimp_color_managed_simulation_bpc_changed (GIMP_COLOR_MANAGED (image));
+
+ str = g_strdup_printf ("%i", bpc ? 1 : 0);
+ parasite = gimp_parasite_new ("image-simulation-bpc",
+ GIMP_PARASITE_PERSISTENT,
+ strlen (str) + 1, (gpointer) str);
+ g_free (str);
+ gimp_image_parasite_attach (image, parasite, FALSE);
+ gimp_parasite_free (parasite);
}
}
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index 95bcd83f59..66275bb99e 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -40,6 +40,7 @@
#include "core/gimpgrid.h"
#include "core/gimpgrouplayer.h"
#include "core/gimpimage.h"
+#include "core/gimpimage-color-profile.h"
#include "core/gimpimage-colormap.h"
#include "core/gimpimage-grid.h"
#include "core/gimpimage-guides.h"
@@ -269,6 +270,80 @@ xcf_load_image (Gimp *gimp,
info->layer_sets = g_list_reverse (info->layer_sets);
info->channel_sets = g_list_reverse (info->channel_sets);
+ /* check for simulation intent parasite */
+ parasite = gimp_image_parasite_find (GIMP_IMAGE (image),
+ "image-simulation-intent");
+ if (parasite)
+ {
+ gchar *parasite_data;
+ guint32 parasite_size;
+ gint intent;
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ parasite_data = (gchar *) gimp_parasite_get_data (parasite, ¶site_size);
+ parasite_data = g_strndup (parasite_data, parasite_size);
+
+ if (sscanf (parasite_data, "%i", &intent) == 1)
+ {
+ if (intent != GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL &&
+ intent != GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC &&
+ intent != GIMP_COLOR_RENDERING_INTENT_SATURATION &&
+ intent != GIMP_COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC)
+ {
+ gimp_message (info->gimp, G_OBJECT (info->progress),
+ GIMP_MESSAGE_ERROR,
+ "Unknown simulation rendering intent: %d",
+ (gint) intent);
+ }
+ else
+ {
+ gimp_image_set_simulation_intent (image,
+ (GimpColorRenderingIntent) intent);
+ }
+ }
+
+ gimp_parasite_list_remove (private->parasites,
+ gimp_parasite_get_name (parasite));
+ g_free (parasite_data);
+ }
+
+/* check for simulation intent parasite */
+ parasite = gimp_image_parasite_find (GIMP_IMAGE (image),
+ "image-simulation-bpc");
+ if (parasite)
+ {
+ gchar *parasite_data;
+ guint32 parasite_size;
+ gint bpc;
+ gboolean status = FALSE;
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ parasite_data = (gchar *) gimp_parasite_get_data (parasite, ¶site_size);
+ parasite_data = g_strndup (parasite_data, parasite_size);
+
+ if (sscanf (parasite_data, "%i", &bpc) == 1)
+ {
+ if (bpc < 0)
+ {
+ gimp_message (info->gimp, G_OBJECT (info->progress),
+ GIMP_MESSAGE_ERROR,
+ "Unknown simulation bpc status: %d",
+ (gint) bpc);
+ }
+ else
+ {
+ if (bpc)
+ status = TRUE;
+
+ gimp_image_set_simulation_bpc (image, status);
+ }
+ }
+
+ gimp_parasite_list_remove (private->parasites,
+ gimp_parasite_get_name (parasite));
+ g_free (parasite_data);
+ }
+
/* check for a GimpGrid parasite */
parasite = gimp_image_parasite_find (GIMP_IMAGE (image),
gimp_grid_parasite_name ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]