Class ColorEncoder

java.lang.Object
org.sunflow.image.ColorEncoder

public final class ColorEncoder extends Object
This class contains many static helper methods that may be helpful for encoding colors into files.
  • Constructor Details

    • ColorEncoder

      public ColorEncoder()
  • Method Details

    • unpremult

      public static final Color[] unpremult(Color[] color, float[] alpha)
      Undoes the premultiplication of the specified color array. The original colors are not modified.
      Parameters:
      color - an array of premultiplied colors
      alpha - alpha values corresponding to the colors
      Returns:
      an array of unpremultiplied colors
    • unlinearize

      public static final Color[] unlinearize(Color[] color)
      Moves the colors in the specified array to non-linear space. The original colors are not modified.
      Parameters:
      color - an array of colors in linear space
      Returns:
      a new array of the same colors in non-linear space
    • quantizeRGB8

      public static final byte[] quantizeRGB8(Color[] color)
      Quantize the specified colors to 8-bit RGB format. The returned array contains 3 bytes for each color in the original array.
      Parameters:
      color - array of colors to quantize
      Returns:
      array of quantized RGB values
    • quantizeRGBA8

      public static final byte[] quantizeRGBA8(Color[] color, float[] alpha)
      Quantize the specified colors to 8-bit RGBA format. The returned array contains 4 bytes for each color in the original array.
      Parameters:
      color - array of colors to quantize
      alpha - array of alpha values (same length as color)
      Returns:
      array of quantized RGBA values
    • encodeRGBE

      public static final int[] encodeRGBE(Color[] color)
      Encode the specified colors using Ward's RGBE technique. The returned array contains one int for each color in the original array.
      Parameters:
      color - array of colors to encode
      Returns:
      array of encoded colors