freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] anuj-distance-field abc9595 80/95: [sdf -> bsdf] Fix edge de


From: Anuj Verma
Subject: [freetype2] anuj-distance-field abc9595 80/95: [sdf -> bsdf] Fix edge detection bug.
Date: Sun, 2 Aug 2020 01:10:41 -0400 (EDT)

branch: anuj-distance-field
commit abc9595ec1b6a9d29a7f5601b944a349be52a692
Author: Anuj Verma <anujv@iitbhilai.ac.in>
Commit: Anuj Verma <anujv@iitbhilai.ac.in>

    [sdf -> bsdf] Fix edge detection bug.
    
    * src/sdf/ftbsdf.c (bsdf_is_edge): [BUG] Check all
      neighbors including the diagonal neighbors to
      properly determine the edge.
---
 [GSoC]ChangeLog  |  8 ++++++++
 src/sdf/ftbsdf.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/[GSoC]ChangeLog b/[GSoC]ChangeLog
index 9d15fea..798b614 100644
--- a/[GSoC]ChangeLog
+++ b/[GSoC]ChangeLog
@@ -1,5 +1,13 @@
 2020-07-27  Anuj Verma  <anujv@iitbhilai.ac.in>
 
+       [sdf -> bsdf] Fix edge detection bug.
+
+       * src/sdf/ftbsdf.c (bsdf_is_edge): [BUG] Check all
+         neighbors including the diagonal neighbors to
+         properly determine the edge.
+
+2020-07-27  Anuj Verma  <anujv@iitbhilai.ac.in>
+
        [sdf -> bsdf] Added edge detection algorithm.
 
        Added edge detection algorithm. It works by checking
diff --git a/src/sdf/ftbsdf.c b/src/sdf/ftbsdf.c
index 004346a..a42c4d4 100644
--- a/src/sdf/ftbsdf.c
+++ b/src/sdf/ftbsdf.c
@@ -107,6 +107,7 @@
     FT_Byte*  to_check      = NULL;
     FT_Int    num_neighbour = 0;
 
+
     if ( y == 7 && x == 20 )
       to_check = NULL;
 
@@ -117,7 +118,7 @@
     if ( y > 0 )
     {
       num_neighbour++;
-      to_check = s -  w;
+      to_check = s - w;
       if ( *to_check == 0 )
       {
         is_edge = 1;
@@ -161,9 +162,55 @@
       }
     }
 
-    
+    /* up left */
+    if ( y > 0 && x > 0 )
+    {
+      num_neighbour++;
+      to_check = s - w - 1;
+      if ( *to_check == 0 )
+      {
+        is_edge = 1;
+        goto Done;
+      }
+    }
+
+    /* up right */
+    if ( y > 0 && x < w - 2 )
+    {
+      num_neighbour++;
+      to_check = s - w + 1;
+      if ( *to_check == 0 )
+      {
+        is_edge = 1;
+        goto Done;
+      }
+    }
+
+    /* down left */
+    if ( y < r - 2 && x > 0 )
+    {
+      num_neighbour++;
+      to_check = s + w - 1;
+      if ( *to_check == 0 )
+      {
+        is_edge = 1;
+        goto Done;
+      }
+    }
+
+    /* down right */
+    if ( y < r - 2 && x < w - 2 )
+    {
+      num_neighbour++;
+      to_check = s + w + 1;
+      if ( *to_check == 0 )
+      {
+        is_edge = 1;
+        goto Done;
+      }
+    }
 
-    if ( num_neighbour != 4 )
+    if ( num_neighbour != 8 )
       is_edge = 1;
 
   Done:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]