[gimp] app: gimp_edgel_region_area() may return < 0 for non-closed zones.



commit 0636c302a394158c2fa36e39fec872569f6de4f2
Author: Jehan <jehan girinstud io>
Date:   Thu Feb 14 13:46:09 2019 +0100

    app: gimp_edgel_region_area() may return < 0 for non-closed zones.
    
    The algorithm to compute a zone area by following its border only works
    well for fully closed zones. It may return negative values otherwise.
    Let's just assume the created zone is big in this case (which may or may
    not be the case, but this is the safe case as it does not prevent
    closure creation).

 app/core/gimplineart.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/app/core/gimplineart.c b/app/core/gimplineart.c
index 5a98c4f2f6..792184dbbc 100644
--- a/app/core/gimplineart.c
+++ b/app/core/gimplineart.c
@@ -1895,7 +1895,7 @@ gimp_line_art_allow_closure (GeglBuffer *mask,
 
                       return FALSE;
                     }
-                  else if (area < significant_size)
+                  else if (area > 0 && area < significant_size)
                     {
                       Pixel *np = g_new (Pixel, 1);
 
@@ -2307,6 +2307,20 @@ gimp_edgel_track_mark (GeglBuffer *mask,
   return count;
 }
 
+/**
+ * gimp_edgel_region_area:
+ * @mask: current state of closed line art buffer.
+ * @start_edgel: edgel to follow.
+ *
+ * Follows a line border, starting from @start_edgel to compute the area
+ * enclosed by this border.
+ * Unfortunately this may return a negative area when the line does not
+ * close a zone. In this case, there is an uncertaincy on the size of
+ * the created zone, and we should consider it a big size.
+ *
+ * Returns: the area enclosed by the followed line, or a negative value
+ * if the zone is not closed (hence actual area unknown).
+ */
 static glong
 gimp_edgel_region_area (const GeglBuffer *mask,
                         Edgel             start_edgel)


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