The Floyd-Steinberg Dithering Algorithm for Thermal Paper Printing #Java
If you’ve ever converted an image to GIF and restricted its color table to 256, you effectively employed the Floyd–Steinberg dithering algorithm. For thermal printers – where the background is typically white and black is probably your only ink color – the challenges are different but you can still achieve remarkable results. Thankfully Pierre Muth walks through the process, all stemming from his Free Beer Selfie project.
To print pictures on thermal paper with reasonably good rendering, they should be converted according the printer limitations. It’s quite simple, it can be printed only black pixels (and whites as the paper is usually white).
As receipt thermal printer use paper roll, there is virtually no image length limit. If we want to convert on the fly the image and strait print it, we cannot rely on a fixe full image sized buffer. That’s why I experimenting conversion algorithm based on Floyd-Steinberg, but with only a small rotating buffer. The size of this ‘line’ buffer could be as small as a line size plus one.
Other than the code itself, I try to explain the principle with this Gif :
Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on code.org, jump into CircuitPython to learn Python and hardware together, or even use Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for MakeCode, CircuitPython, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.