From: Niki Roo Date: Thu, 12 Apr 2018 17:20:41 +0000 (+0200) Subject: image to text: improve DOUBLE_DITHERING X-Git-Tag: fanfix-swing-0.0.1~21^2~206 X-Git-Url: http://git.nikiroo.be/?a=commitdiff_plain;h=9db215c6238d776d39dae5b7c8d805cb6f4e9bd1;p=fanfix-swing.git image to text: improve DOUBLE_DITHERING --- diff --git a/src/be/nikiroo/utils/ui/ImageTextAwt.java b/src/be/nikiroo/utils/ui/ImageTextAwt.java index 8fdaa866..4c0c8248 100644 --- 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 '█';