From 9db215c6238d776d39dae5b7c8d805cb6f4e9bd1 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Thu, 12 Apr 2018 19:20:41 +0200 Subject: [PATCH] image to text: improve DOUBLE_DITHERING --- src/be/nikiroo/utils/ui/ImageTextAwt.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/be/nikiroo/utils/ui/ImageTextAwt.java b/src/be/nikiroo/utils/ui/ImageTextAwt.java index 8fdaa86..4c0c824 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 '█'; -- 2.27.0