Class Dithering


  • public final class Dithering
    extends java.lang.Object
    Dithering algorithms to use when quantizing an image to paletted form.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Dithering()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static int adjustPixel​(int argb, int errA, int errR, int errG, int errB, int mul)  
      static void applyFloydSteinbergDithering​(java.awt.image.BufferedImage image, Palette palette)
      Changes the given image to only use colors from the given palette, applying Floyd-Steinberg dithering in the process.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Dithering

        private Dithering()
    • Method Detail

      • applyFloydSteinbergDithering

        public static void applyFloydSteinbergDithering​(java.awt.image.BufferedImage image,
                                                        Palette palette)
                                                 throws ImageWriteException
        Changes the given image to only use colors from the given palette, applying Floyd-Steinberg dithering in the process. Ensure that your alpha values in the image and in the palette are consistent.
        Parameters:
        image - the image to change
        palette - the palette to use
        Throws:
        ImageWriteException - if it fails to read the palette index
      • adjustPixel

        private static int adjustPixel​(int argb,
                                       int errA,
                                       int errR,
                                       int errG,
                                       int errB,
                                       int mul)