cacalabs / libcaca

💩 Colour ASCII Art Library
Do What The F*ck You Want To Public License
520 stars 71 forks source link

Black and white levels are wrong when using dither #3

Open wheany opened 9 years ago

wheany commented 9 years ago

When converting a totally black or white image, such as black and white

The resulting output looks like this:

img2txt -W 10 -H 10 -d ordered8 white.png
@ S @ S @
 t : t : t
% X % X %
 . ; . ; .
X % @ S X
 ; . t : ;
t S % X t
   : . ;
@ S @ S @
 t : t : t
img2txt -W 10 -H 10 -d ordered8 black.png
   .   :
; S ; S ;
 : . : . :
X ; X % X
   :   .
; X ; S ;
 : . : . :
@ S X ; @
   .   :
; S ; S ;

In the white example the background color is white and the characters are light gray. In the black example, the background is black and the characters are blue and dark gray. If you don't specify a dithering algorithm (so it uses the default Floyd-Steinberg one), the black example looks correct, i.e. black background with space characters. The white example looks like this:

img2txt -W 10 -H 10 white.png

  .  . .
   .     .
     .
 .     .
   .  .  .
  .
    .  .
  .     .
    . .

Again, the background is white and the periods in the output are light gray

When using no dithering (-d none), both outputs look correct.