Packages

 

com.aspose.imaging

Interfaces

Classes

Exceptions

com.aspose.imaging

Class DitheringMethod

  • java.lang.Object
    • com.aspose.ms.System.ValueType<com.aspose.ms.System.Enum>
      • com.aspose.ms.System.Enum
        • com.aspose.imaging.DitheringMethod


  • public final class DitheringMethod
    extends com.aspose.ms.System.Enum

    Dithering method.

    Code example:

    The following example loads a raster image and performs threshold and floyd dithering using different palette depth.


    String dir = "c:\\temp\\";
    
    com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.png");
    try {
        com.aspose.imaging.RasterImage rasterImage = (com.aspose.imaging.RasterImage) image;
    
        // Perform threshold dithering using 4-bit color palette which contains 16 colors.
        // The more bits specified the higher quality and the bigger size of the output image.
        // Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
        rasterImage.dither(com.aspose.imaging.DitheringMethod.ThresholdDithering, 4);
    
        rasterImage.save(dir + "sample.ThresholdDithering4.png");
    } finally {
        image.dispose();
    }
    
    image = com.aspose.imaging.Image.load(dir + "sample.png");
    try {
        com.aspose.imaging.RasterImage rasterImage = (com.aspose.imaging.RasterImage) image;
    
        // Perform floyd dithering using 1-bit color palette which contains only 2 colors - black and white.
        // The more bits specified the higher quality and the bigger size of the output image.
        // Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
        rasterImage.dither(com.aspose.imaging.DitheringMethod.FloydSteinbergDithering, 1);
    
        rasterImage.save(dir + "sample.FloydSteinbergDithering1.png");
    } finally {
        image.dispose();
    }
    

    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.aspose.ms.System.Enum

        com.aspose.ms.System.Enum.AbstractEnum, com.aspose.ms.System.Enum.FlaggedEnum, com.aspose.ms.System.Enum.ObjectEnum, com.aspose.ms.System.Enum.SimpleEnum
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static int FloydSteinbergDithering
      The Floyd-Steinberg dithering.
      static int ThresholdDithering
      Threshold dithering.
      • Fields inherited from class com.aspose.ms.System.Enum

        EnumSeparatorCharArray
    • Method Summary

      • Methods inherited from class com.aspose.ms.System.Enum

        Clone, CloneTo, format, format, get_Caption, get_Value, getName, getName, getNames, getNames, getNames, getUnderlyingType, getUnderlyingType, getValue, getValues, getValues, getValues, isDefined, isDefined, isDefined, isDefined, parse, parse, parse, parse, register, toObject, toString
    • Field Detail

      • ThresholdDithering

        public static final int ThresholdDithering

        Threshold dithering. Simplest and fastest dithering algorithm.

        See Also:
        Constant Field Values
      • FloydSteinbergDithering

        public static final int FloydSteinbergDithering

        The Floyd-Steinberg dithering. A more complex dithering algorithm, uses nearest neighbors intensity values.

        See Also:
        Constant Field Values