- java.lang.Object
-
- java.lang.Enum<ColorDepth>
-
- org.refcodes.graphical.ColorDepth
-
- All Implemented Interfaces:
Serializable
,Comparable<ColorDepth>
public enum ColorDepth extends Enum<ColorDepth>
Enumeration providing definitions for common color depths used by various raster image formats (pixmaps).
-
-
Enum Constant Summary
Enum Constants Enum Constant Description AWT_COLOR_24_BIT
GRAYSCALE_8_BIT
HIGH_COLOR_16_BIT
MONOCHROME_1_BIT
MSX_8_BIT
TRUE_COLOR_24_BIT
TRUE_COLOR_32_BIT
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getAlphaBits()
The number of bits for the "alpha" portion.int
getBits()
The overall number of bits per pixel.int
getBlueBits()
The number of bits for the "blue" portion.int
getBytes()
Returns the number of bytes required to store the color value.int
getGreenBits()
The number of bits for the "green" portion.int
getMaxAlphaValue()
The max value of for the "alpha" portion.int
getMaxBlueValue()
The max value of for the "blue" portion.int
getMaxGreenValue()
The max value of for the "green" portion.int
getMaxRedValue()
The max value of for the "red" portion.int
getMaxValue()
The overall max value of per pixel.int
getRedBits()
The number of bits for the "red" portion.boolean
isMonochrome()
Specifies whether theColorDepth
has neither RGB nor ALPHA portions.int
toAlphaValue(int aColorValue)
Retrieves the value of the alpha portion for the provided color value (being of the currentColorDepth
format).int
toBlueValue(int aColorValue)
Retrieves the value of the blue portion for the provided color value (being of the currentColorDepth
format).int
toColor(int aColor, ColorDepth aColorDepth)
Converts a color from one color depth to another color depth.int
toGreenValue(int aColorValue)
Retrieves the value of the green portion for the provided color value (being of the currentColorDepth
format).int
toRedValue(int aColorValue)
Retrieves the value of the red portion for the provided color value (being of the currentColorDepth
format).static ColorDepth
valueOf(String name)
Returns the enum constant of this type with the specified name.static ColorDepth[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
MONOCHROME_1_BIT
public static final ColorDepth MONOCHROME_1_BIT
-
GRAYSCALE_8_BIT
public static final ColorDepth GRAYSCALE_8_BIT
-
MSX_8_BIT
public static final ColorDepth MSX_8_BIT
-
HIGH_COLOR_16_BIT
public static final ColorDepth HIGH_COLOR_16_BIT
-
TRUE_COLOR_24_BIT
public static final ColorDepth TRUE_COLOR_24_BIT
-
AWT_COLOR_24_BIT
public static final ColorDepth AWT_COLOR_24_BIT
-
TRUE_COLOR_32_BIT
public static final ColorDepth TRUE_COLOR_32_BIT
-
-
Method Detail
-
values
public static ColorDepth[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (ColorDepth c : ColorDepth.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ColorDepth valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
getBits
public int getBits()
The overall number of bits per pixel.- Returns:
- the bits
-
getBytes
public int getBytes()
Returns the number of bytes required to store the color value. ForColorDepth
values with less than 8 bits per color, 1 will be returned, although a byte may contain more than one color. E.g.MONOCHROME_1_BIT
can store up to 8 color per byte!- Returns:
- The number of bytes for the color value.
-
getRedBits
public int getRedBits()
The number of bits for the "red" portion.- Returns:
- the red
-
getGreenBits
public int getGreenBits()
The number of bits for the "green" portion.- Returns:
- the green
-
getBlueBits
public int getBlueBits()
The number of bits for the "blue" portion.- Returns:
- the blue
-
getAlphaBits
public int getAlphaBits()
The number of bits for the "alpha" portion.- Returns:
- the alpha
-
getMaxValue
public int getMaxValue()
The overall max value of per pixel.- Returns:
- the max value for
-
getMaxRedValue
public int getMaxRedValue()
The max value of for the "red" portion.- Returns:
- the max value for red
-
getMaxGreenValue
public int getMaxGreenValue()
The max value of for the "green" portion.- Returns:
- the max value for green
-
getMaxBlueValue
public int getMaxBlueValue()
The max value of for the "blue" portion.- Returns:
- the max value for blue
-
getMaxAlphaValue
public int getMaxAlphaValue()
The max value of for the "alpha" portion.- Returns:
- the max value for alpha
-
isMonochrome
public boolean isMonochrome()
Specifies whether theColorDepth
has neither RGB nor ALPHA portions. The color just specifies the brightness (in terms of greay scale or monochrome).- Returns:
- The in case the color dies not have any RGB nor ALPHA portions!
-
toAlphaValue
public int toAlphaValue(int aColorValue)
Retrieves the value of the alpha portion for the provided color value (being of the currentColorDepth
format).- Parameters:
aColorValue
- A color value of the currentColorDepth
format- Returns:
- The according alpha portion.
-
toRedValue
public int toRedValue(int aColorValue)
Retrieves the value of the red portion for the provided color value (being of the currentColorDepth
format).- Parameters:
aColorValue
- A color value of the currentColorDepth
format- Returns:
- The according red portion.
-
toGreenValue
public int toGreenValue(int aColorValue)
Retrieves the value of the green portion for the provided color value (being of the currentColorDepth
format).- Parameters:
aColorValue
- A color value of the currentColorDepth
format- Returns:
- The according green portion.
-
toBlueValue
public int toBlueValue(int aColorValue)
Retrieves the value of the blue portion for the provided color value (being of the currentColorDepth
format).- Parameters:
aColorValue
- A color value of the currentColorDepth
format- Returns:
- The according blue portion.
-
toColor
public int toColor(int aColor, ColorDepth aColorDepth)
Converts a color from one color depth to another color depth.- Parameters:
aColor
- The color to be converted.aColorDepth
- TheColorDepth
of the proided color.- Returns:
- The converted color.
-
-