summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnuj Verma <anujv@iitbhilai.ac.in>2020-07-27 10:56:40 +0530
committeranujverma <anujv@iitbhilai.ac.in>2020-08-02 16:33:21 +0530
commit262e9649f385a82bb460741bd729bd35817984cd (patch)
tree89004467853a7eb2b20114296745a44a299b5593
parentf057095bef5133f152f56c560fc0e30e8a85262b (diff)
downloadfreetype2-262e9649f385a82bb460741bd729bd35817984cd.tar.gz
[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.
-rw-r--r--[GSoC]ChangeLog8
-rw-r--r--src/sdf/ftbsdf.c53
2 files changed, 58 insertions, 3 deletions
diff --git a/[GSoC]ChangeLog b/[GSoC]ChangeLog
index 9d15fea09..798b61495 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 004346a04..a42c4d4a4 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: