git://git.nikiroo.be
/
fanfix.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c0c091a
)
image to text: improve DOUBLE_DITHERING
author
Niki Roo
<niki@nikiroo.be>
Thu, 12 Apr 2018 17:20:41 +0000
(19:20 +0200)
committer
Niki Roo
<niki@nikiroo.be>
Thu, 12 Apr 2018 17:20:41 +0000
(19:20 +0200)
src/be/nikiroo/utils/ui/ImageTextAwt.java
patch
|
blob
|
blame
|
history
diff --git
a/src/be/nikiroo/utils/ui/ImageTextAwt.java
b/src/be/nikiroo/utils/ui/ImageTextAwt.java
index 8fdaa866b2357aa30aec72e1ba1dff042feb7d41..4c0c82483e640d47603d3e5f75d4f1751c284bc6 100644
(file)
--- a/
src/be/nikiroo/utils/ui/ImageTextAwt.java
+++ b/
src/be/nikiroo/utils/ui/ImageTextAwt.java
@@
-389,7
+389,13
@@
public class ImageTextAwt {
avg += getBrightness(lowerright);
avg /= 4;
- return getDitheringChar(avg, " ░▒▓█");
+ // Since all the quarters are > 0.5, avg is between 0.5 and 1.0
+ // So, expand the range of the value
+ avg = (avg - 0.5f) * 2;
+
+ // Do not use the " " char, as it would make a
+ // "all quarters > 0.5" pixel go black
+ return getDitheringChar(avg, "░▒▓█");
}
return '█';