[gimp] app: save images with fractional grid coordinates as version-10 XCFs



commit a90322278dbf4cc7b63c41d6bcc18b537dd8b109
Author: Ell <ell_se yahoo com>
Date:   Wed Dec 5 13:28:04 2018 -0500

    app: save images with fractional grid coordinates as version-10 XCFs
    
    Fractional-coordinate support for image grids was added in commit
    1572bccc9f1f781b720bb030730f34a1f59c498b, right before the
    introduction of XCF version 10.  While images with fractional grid
    coordinates can be loaded with earilier versions of GIMP, the grid
    coordinates are rounded to the nearest integer.
    
    Bump the minimal XCF version when saving images with fractional
    grid coordinates to 10, which should have been the case all along.

 app/core/gimpimage.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 3e165cb6c9..0204658543 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -53,6 +53,7 @@
 #include "gimpimage-color-profile.h"
 #include "gimpimage-colormap.h"
 #include "gimpimage-guides.h"
+#include "gimpimage-grid.h"
 #include "gimpimage-item-list.h"
 #include "gimpimage-metadata.h"
 #include "gimpimage-sample-points.h"
@@ -2525,6 +2526,25 @@ gimp_image_get_xcf_version (GimpImage    *image,
       version = MAX (7, version);
     }
 
+  /* need version 10 for fractional grid coordinates */
+  if (gimp_image_get_grid (image))
+    {
+      GimpGrid *grid = gimp_image_get_grid (image);
+      gdouble   xspacing, yspacing;
+      gdouble   xoffset,  yoffset;
+
+      gimp_grid_get_spacing (grid, &xspacing, &yspacing);
+      gimp_grid_get_offset  (grid, &xoffset,  &yoffset);
+
+      if (xspacing != floor (xspacing) || yspacing != floor (yspacing) ||
+          xoffset  != floor (xoffset)  || yoffset  != floor (yoffset))
+        {
+          ADD_REASON (g_strdup_printf (_("Fractional grid coordinates were "
+                                         "added in %s"), "GIMP 2.10"));
+          version = MAX (10, version);
+        }
+    }
+
   /* need version 12 for > 8-bit images for proper endian swapping */
   if (gimp_image_get_component_type (image) > GIMP_COMPONENT_TYPE_U8)
     {


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