I got really bored so I wrote a simple dithering tool in Kotlin. It is surprising how little loss you get when reducing an image to 8 colors. Source code: gist.github.com/Frederikam/115

Wow that's quite something. I guess it's kind of like using more than one pixel as a pixel, displaying the colour using a number of dots... presumably it can't be saved as a jpeg though? Is it a png?

@puffinux It can be saved as JPG, but the result is quite poor

The algorithm only deals with one pixel at a time, but tries to distribute the errors to unprocessed pixels, creating more balance

Interesting... I've heard people say that as it reduces file size, it's a useful technique for sites that operate on poor internet speeds / for people browsing with slow internet.

@puffinux In theory you could represent a pixel as 3 bits without further compression

I'm not sure how that compares to other image encodings, but that would certainly be interesting... some sort of header defining it as an image, a load of binary, and something to close it off...


@puffinux I think that's more or less how PNGs work, with some lossless compression as well

Oh right 😅 I don't know what I'm talking about. Just thinking it through I guess.

Sign in to participate in the conversation

Welcome to your niu world ! We are a cute and loving international community O(≧▽≦)O !