[gimp/alxsa-cmyk-jpeg-stored: 2/2] plug-ins: Use CMYK profile stored in GimpImage




commit 0f323d027924b110fbd29caf3d04869cf6a95b70
Author: Alx Sa <cmyk student gmail com>
Date:   Tue Jul 19 10:56:32 2022 +0000

    plug-ins: Use CMYK profile stored in GimpImage
    
    CMYK profile is now stored in GimpImage on load
    (rather than being discarded) and it's used for export rather than
    the default simulation profile stored in Preferences

 plug-ins/file-jpeg/jpeg-load.c | 13 +++++++++----
 plug-ins/file-jpeg/jpeg-save.c |  9 ++++-----
 plug-ins/file-jpeg/jpeg-save.h |  3 ++-
 plug-ins/file-jpeg/jpeg.c      |  2 +-
 4 files changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/plug-ins/file-jpeg/jpeg-load.c b/plug-ins/file-jpeg/jpeg-load.c
index 2d227ee0cc..ef7fa4eb92 100644
--- a/plug-ins/file-jpeg/jpeg-load.c
+++ b/plug-ins/file-jpeg/jpeg-load.c
@@ -346,11 +346,16 @@ load_image (GFile        *file,
     {
       encoding = "cmyk u8";
       if (cmyk_profile)
-        space = gimp_color_profile_get_space (cmyk_profile,
-                                              GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
-                                              error);
+        {
+          space = gimp_color_profile_get_space (cmyk_profile,
+                                                GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
+                                                error);
+          gimp_image_set_simulation_profile (image, cmyk_profile);
+        }
       else
-        space = NULL;
+        {
+          space = NULL;
+        }
     }
   else
     {
diff --git a/plug-ins/file-jpeg/jpeg-save.c b/plug-ins/file-jpeg/jpeg-save.c
index 184b6cb798..099a99729d 100644
--- a/plug-ins/file-jpeg/jpeg-save.c
+++ b/plug-ins/file-jpeg/jpeg-save.c
@@ -213,7 +213,6 @@ save_image (GFile                *file,
   FILE             * volatile outfile;
   guchar           *data;
   guchar           *src;
-  GimpColorConfig  *color_config = gimp_get_color_configuration ();
   GimpColorProfile *profile      = NULL;
   GimpColorProfile *cmyk_profile = NULL;
 
@@ -436,7 +435,7 @@ save_image (GFile                *file,
         {
           GError *err = NULL;
 
-          cmyk_profile = gimp_color_config_get_simulation_color_profile (color_config, &err);
+          cmyk_profile = gimp_image_get_simulation_profile (image);
           if (! cmyk_profile && err)
             g_printerr ("%s: no soft-proof profile: %s\n", G_STRFUNC, err->message);
 
@@ -838,13 +837,13 @@ destroy_preview (void)
 gboolean
 save_dialog (GimpProcedure       *procedure,
              GimpProcedureConfig *config,
-             GimpDrawable        *drawable)
+             GimpDrawable        *drawable,
+             GimpImage           *image)
 {
   GtkWidget        *dialog;
   GtkWidget        *widget;
   GtkWidget        *profile_label;
   GtkListStore     *store;
-  GimpColorConfig  *color_config = gimp_get_color_configuration ();
   GimpColorProfile *cmyk_profile = NULL;
   gint              orig_quality;
   gint              restart;
@@ -900,7 +899,7 @@ save_dialog (GimpProcedure       *procedure,
   gimp_procedure_dialog_fill_frame (GIMP_PROCEDURE_DIALOG (dialog),
                                     "cmyk-frame", "cmyk", FALSE,
                                     "profile-label");
-  cmyk_profile = gimp_color_config_get_simulation_color_profile (color_config, NULL);
+  cmyk_profile = gimp_image_get_simulation_profile (image);
   if (cmyk_profile)
     {
       if (gimp_color_profile_is_cmyk (cmyk_profile))
diff --git a/plug-ins/file-jpeg/jpeg-save.h b/plug-ins/file-jpeg/jpeg-save.h
index 14acc47864..4c98acb0f0 100644
--- a/plug-ins/file-jpeg/jpeg-save.h
+++ b/plug-ins/file-jpeg/jpeg-save.h
@@ -32,6 +32,7 @@ gboolean    save_image         (GFile                *file,
                                 GError              **error);
 gboolean    save_dialog        (GimpProcedure        *procedure,
                                 GimpProcedureConfig  *config,
-                                GimpDrawable         *drawable);
+                                GimpDrawable         *drawable,
+                                GimpImage            *image);
 
 #endif /* __JPEG_SAVE_H__ */
diff --git a/plug-ins/file-jpeg/jpeg.c b/plug-ins/file-jpeg/jpeg.c
index d136085274..9307b71c07 100644
--- a/plug-ins/file-jpeg/jpeg.c
+++ b/plug-ins/file-jpeg/jpeg.c
@@ -590,7 +590,7 @@ jpeg_save (GimpProcedure        *procedure,
       drawable_global   = drawables[0];
 
       /*  First acquire information with a dialog  */
-      if (! save_dialog (procedure, config, drawables[0]))
+      if (! save_dialog (procedure, config, drawables[0], orig_image))
         {
           status = GIMP_PDB_CANCEL;
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]