How to convert a 24 Bit PNG to 3 Bit PNG using Floyd–Steinberg dithering? java.awt.image.BufferedImage should be used to get and set RGB values.
On wikipedia, an example is given on how to convert a 16 Bit to a 8 Bit image:
find_closest_palette_color(oldpixel) = (oldpixel + 128) / 256
Based on this, are there any ideas on how to fit the example above in order to achieve the goal?
Use
image.getRGB(x, y)andimage.setRGB(x, y, color)and use the pseudocode from the wikipedia article. Note that code on the wiki does not say how to “subtract”, “add” and “multiply” colors. (TheT3class below handles “color” manipulation.)The code below will produce this screenshot: