Package org.sunflow.image
Class ColorEncoder
java.lang.Object
org.sunflow.image.ColorEncoder
This class contains many static helper methods that may be helpful for
encoding colors into files.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final int[]
encodeRGBE
(Color[] color) Encode the specified colors using Ward's RGBE technique.static final byte[]
quantizeRGB8
(Color[] color) Quantize the specified colors to 8-bit RGB format.static final byte[]
quantizeRGBA8
(Color[] color, float[] alpha) Quantize the specified colors to 8-bit RGBA format.static final Color[]
unlinearize
(Color[] color) Moves the colors in the specified array to non-linear space.static final Color[]
Undoes the premultiplication of the specified color array.
-
Constructor Details
-
ColorEncoder
public ColorEncoder()
-
-
Method Details
-
unpremult
Undoes the premultiplication of the specified color array. The original colors are not modified.- Parameters:
color
- an array of premultiplied colorsalpha
- alpha values corresponding to the colors- Returns:
- an array of unpremultiplied colors
-
unlinearize
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
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
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 quantizealpha
- array of alpha values (same length as color)- Returns:
- array of quantized RGBA values
-
encodeRGBE
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
-