Package java.awt.image |
![]() Previous |
![]() Java API |
![]() Index |
![]() Next |
public abstract class java.awt.image.ColorModel extends java.lang.Object { // Fields protected int pixel_bits; // Constructors public ColorModel(int bits); // Methods public abstract int getAlpha(int pixel); public abstract int getBlue(int pixel); public abstract int getGreen(int pixel); public int getPixelSize(); public abstract int getRed(int pixel); public int getRGB(int pixel); public static ColorModel getRGBdefault(); }
This abstract class is the superclass for all classes that encapsulate methods for translating from pixel values to their alpha (transparency), red, green, and blue components.
The java.awt.image classes IndexColorModel and DirectColorModel are subclasses of this class.
protected int pixel_bitsThe number of bits per pixel.
public ColorModel(int bits)Constructs a ColorModel which describes a pixel with the specified number of bits.
Parameter Description bits the number of bits per pixel
public abstract int getAlpha(int pixel)Determines the alpha transparency of a pixel in this color model. The value ranges from 0 to 255. The value 0 indicates that the pixel is completely transparent. The value 255 indicates that the pixel is opaque.
Return Value:
Returns the alpha transparency represented by the pixel value.
Parameter Description pixel a pixel value
public abstract int getBlue(int pixel)Determines the blue component of a pixel in this color model. The value ranges from 0 to 255. The value 0 indicates no contribution from this primary color. The value 255 indicates the maximum intensity of this color component.
Return Value:
Returns the blue color component represented by the pixel value.
Parameter Description pixel a pixel value
public abstract int getGreen(int pixel)Determines the green component of a pixel in this color model. The value ranges from 0 to 255. The value 0 indicates no contribution from this primary color. The value 255 indicates the maximum intensity of this color component.
Return Value:
Returns The green color component ranging from 0 to 255
Parameter Description pixel a pixel value
public int getPixelSize()Return Value:
Returns the number of bits per pixel in this color model.
public abstract int getRed(int pixel)Determines the red component of a pixel in this color model. The value ranges from 0 to 255. The value 0 indicates no contribution from this primary color. The value 255 indicates the maximum intensity of this color component.
Return Value:
Returns the red color component ranging from 0 to 255
Parameter Description pixel a pixel value
public int getRGB(int pixel)Calculates a single integer representing the alpha, red, green, and blue components of a pixel in this color model. The components are each scaled to be a value between 0 and 255 . The integer returned is the number such that bits 24-31 are the alpha value, 16-23 are the red value, bits 8-15 are the green value, and bits 0-7 are the blue value.
Return Value:
Returns an integer representing this color in RGB format.
Parameter Description pixel a pixel value See Also: getRGBdefault .
public static ColorModel getRGBdefault()Returns the default Abstract Window Toolkit color model.
The Abstract Window Toolkit represents each pixel as a 32-bit integer. Bits 24-31 are the alpha transparency, bits 16-23 are the red value, bits 8- 15 are the green value, and bits 0-7 are the blue value.
This method returns a ColorModel object which describes that pixel format and can be used to extract alpha, red, green, and blue values from such color values.
Return Value:
Returns the default Abstract Window Toolkit color model.