[gimp] app, plug-ins: make sure a GIH brush's spacing is preserved



commit 0710051e2b822370e77169417867ef73f76335c4
Author: Michael Natterer <mitch gimp org>
Date:   Tue May 28 00:25:47 2019 +0200

    app, plug-ins: make sure a GIH brush's spacing is preserved
    
    across load and save, by introducing a gimp-brush-pipe-spacing
    parasite.

 app/file-data/file-data-gih.c | 10 ++++++++++
 plug-ins/common/file-gih.c    | 18 ++++++++++++++++++
 2 files changed, 28 insertions(+)
---
diff --git a/app/file-data/file-data-gih.c b/app/file-data/file-data-gih.c
index 039491add6..07da2f349b 100644
--- a/app/file-data/file-data-gih.c
+++ b/app/file-data/file-data-gih.c
@@ -171,6 +171,7 @@ file_gih_pipe_to_image (Gimp          *gimp,
   const gchar       *name;
   GimpImageBaseType  base_type;
   GimpParasite      *parasite;
+  gchar              spacing[8];
   gint               i;
 
   if (gimp_brush_get_pixmap (pipe->current))
@@ -189,6 +190,15 @@ file_gih_pipe_to_image (Gimp          *gimp,
   gimp_image_parasite_attach (image, parasite);
   gimp_parasite_free (parasite);
 
+  g_snprintf (spacing, sizeof (spacing), "%d",
+              gimp_brush_get_spacing (GIMP_BRUSH (pipe)));
+
+  parasite = gimp_parasite_new ("gimp-brush-pipe-spacing",
+                                GIMP_PARASITE_PERSISTENT,
+                                strlen (spacing) + 1, spacing);
+  gimp_image_parasite_attach (image, parasite);
+  gimp_parasite_free (parasite);
+
   for (i = 0; i < pipe->n_brushes; i++)
     {
       GimpLayer *layer;
diff --git a/plug-ins/common/file-gih.c b/plug-ins/common/file-gih.c
index 2a490ac012..1f3e69e3f8 100644
--- a/plug-ins/common/file-gih.c
+++ b/plug-ins/common/file-gih.c
@@ -256,6 +256,14 @@ run (const gchar      *name,
 
               g_free (name);
             }
+
+          parasite = gimp_image_get_parasite (orig_image_ID,
+                                              "gimp-brush-pipe-spacing");
+          if (parasite)
+            {
+              info.spacing = atoi (gimp_parasite_data (parasite));
+              gimp_parasite_free (parasite);
+            }
           break;
 
         default:
@@ -344,6 +352,7 @@ run (const gchar      *name,
         {
           GimpParam *save_retvals;
           gint       n_save_retvals;
+          gchar      spacing[8];
           gchar     *paramstring;
 
           paramstring = gimp_pixpipe_params_build (&gihparams);
@@ -372,6 +381,15 @@ run (const gchar      *name,
               gimp_image_attach_parasite (orig_image_ID, parasite);
               gimp_parasite_free (parasite);
 
+              g_snprintf (spacing, sizeof (spacing), "%d",
+                          info.spacing);
+
+              parasite = gimp_parasite_new ("gimp-brush-pipe-spacing",
+                                            GIMP_PARASITE_PERSISTENT,
+                                            strlen (spacing) + 1, spacing);
+              gimp_image_attach_parasite (orig_image_ID, parasite);
+              gimp_parasite_free (parasite);
+
               parasite = gimp_parasite_new ("gimp-brush-pipe-parameters",
                                             GIMP_PARASITE_PERSISTENT,
                                             strlen (paramstring) + 1,


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