22 comments

[ 5.1 ms ] story [ 60.5 ms ] thread
Ordered dithering may match what Windows does in 16 bit mode, to recreate that look, but you can't call it "period appropriate", given that Floyd-Steinberg was published in 1976, well before the first line of Windows was written (and just three years after Bayer).
I call ordered dithering "period-appropriate" because it is what software and hardware implemented at the time for real-time dithering. I don't mean to imply other dithering algorithms hadn't been invented. Did any other reader interpret it like that?

Edit: Rather than wait for replies, I went ahead and changed the phrasing anyway. Thanks!

no, no one else read it like that.

more than one thing can be period-appropriate.

Curious: is the significant palette shift purely a byproduct of the limited bits per color? Or is that somehow baked into the high color format? For example the anime image gets much bluer than I would have expected. Is that a tunable parameter or just how well you can possibly do within the constraints of the format?
You can absolutely make hi-color images which are close to visually indistinguishable from the 24 bit originals, by using a good dither matrix. GdkRgb did this well over 20 years ago, back when "CRT" meant a display technology, and the fuzziness made the dither patterns melt.

If you were doing it really carefully, you'd use a corrective gamma function, as dithering in a nonlinear colorspace is not an identity transfer function. Alternatively, you can do error diffusion in a linear space. But at 5 bits, the effect is fairly subtle.

Thanks — that accords with my intuition but your detailed explanation is excellent.
Even 256 colours at high DPI can look pretty good with an intelligent dither.
The palette shift is an artifact of the current dithering (quantization) algorithm [1]. It becomes visible when you apply quantization a few times to the same image. (50 in the example. I've updated the image and replaced the "After" label with "Gen 50" to make this more obvious.) It won't be too visible to the human eye after a single quantization pass.

Edit: The result of a single pass for the anime image looks like this: https://i.imgur.com/dTmzRwF.png. I've changed "visible" to "too visible" above, because the image is visibly a little brighter.

[1] https://github.com/dbohdan/hicolor/blob/f00eac41417b0e989e1e...

Wasn’t dithering only visible in Windows when using 256-color mode? Bonus for switching apps and having to wait that fraction of a second when the palette was swapped, so you’d possibly see the program you just alt-tabbed to in radically different colors.
When I got the idea to write HiColor, I was thinking about the PlayStation's dithering the most.

https://www.chrismcovell.com/psxdither.html

I think Windows never applied whole-screen dithering on the desktop in 16-bit color mode. Some UI elements, applications, and games, however, did their own dithering. (Maybe in Direct3D and OpenGL it was up to the graphics card drivers? I am not sure. I couldn't confirm or refute this with a quick search.) As an example from Windows itself, I switched a Windows 2000 VM to high color, and the gradients in the window title bars became dithered.

https://i.imgur.com/jrzdcNq.png (top is 32-bit color, bottom is 16-bit)

"It works at least on Linux and Windows 98 Second Edition, 2000 Service Pack 4, XP, and 7." Wonder if author actually tested on Win98SE in 2021 :-)
Can you do this in a VM?
Yes, but the author is most likely using a Win API that is known to exist since that operating system & service pack. I doubt they tested every version, unless they are the curious type :)
I did test it! I had no VM with Windows 98 SE already installed, so instead I used someone's "Windows 98 Live CD" from the Internet Archive. I integrated hicolor.exe and some test pictures into the ISO with ISO Master and booted qemu-system-i386 from it. The program passed manual testing. I realized I could automate the ISO mastering with a shell script and the actual testing with a BAT file to create a Windows 9x approximation of fresh-VM CI without messing with HDD snapshots, but (somehow!) decided not to. I don't think I will be integrating Windows 98 SE or Windows 2000 into the CI pipeline, so support for either may break.
Awesome. Feeling nostalgia now :-D
By great coincidence, I've been working on dithering on my 256-color computer. So far I have greyscale: https://merveilles.town/@akkartik/106561555110196484

I should have color in a few hours.

Hello, fellow traveler! I'm using Floyd-Steinberg and don't depend on C (either directly or indirectly)

Neat. Are you going to apply Floyd-Steinberg to moving images? It is good for still pictures, but I wouldn't use it for real-time graphics unless I was deliberately going for a "jittery" effect. Consider a spatially stable dither like Bayer's or https://pippin.gimp.org/a_dither/ instead.
Good to know! I hadn't thought that far. This is a pretty low-power computer, so video hasn't been a priority.. I think I'm going to shoot to render internet in a box corpuses. Wikipedia, Gutenberg, stuff like that.
What does "git style" mean for a CLI?
An example of "classic style" CLI would be ImageMagick:

  convert infile.png -dither FloydSteinberg -colors 64 outfile.gif   
"Git style" would instead be something like

  convert dither --algorithm FloydSteinberg --colors 64 infile.png outfile.gif
Probably that it uses subcommands, e.g. git apply.
Install mtpaint (or gimp).

->Converted to indexed (or modify palette), select amount of bits. -> select palette algorithm and dithering (mtpaint has option for small palettes) -> save