Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.jimi.core.util
Class GrayscaleColorModel

    java.lang.Object
      |
      +--java.awt.image.ColorModel
            |
            +--com.sun.jimi.core.util.GrayscaleColorModel

public class GrayscaleColorModel
extends java.awt.image.ColorModel

ColorModel for grayscale images. Allows for pixels of a given bit depth to directly represent a grayscale value.

Possible future optimisation might include a generated internal lookup table to make the individual get methods more efficient.

This class is flexible in that it can be used for black and white images and any bit depth grayscale image from 1 to 8 bits in depth.

Examples of use:

- Black and White image where pixels of value 0 are white
  new GrayscaleColorModel(true, 1);
- Common usage case for 8 bit depth grayscale image
  new GrayscaleColorModel(true);

Fields inherited from class java.awt.image.ColorModel
`pixel_bits, transferType`

Constructor Summary
`GrayscaleColorModel(boolean zeroIsWhite)` Constructs a GrayColorModel.
`GrayscaleColorModel(boolean zeroIsWhite, int pixelSize)`

Method Summary
`int` | `getAlpha(int pixel)`
`int` | `getBlue(int pixel)`
`int` | `getGreen(int pixel)`
`int` | `getRed(int pixel)`
`int` | `getRGB(int pixel)` Returns the color of the pixel in the default RGB color model.
`boolean` | `getZeroIsWhite()`
`protected void` | `init(boolean zeroIsWhite)`

Methods inherited from class java.awt.image.ColorModel
`coerceData, createCompatibleSampleModel, createCompatibleWritableRaster, equals, finalize, getAlpha, getAlphaRaster, getBlue, getColorSpace, getComponents, getComponents, getComponentSize, getComponentSize, getDataElement, getDataElements, getDataElements, getGreen, getNormalizedComponents, getNumColorComponents, getNumComponents, getPixelSize, getRed, getRGB, getRGBdefault, getTransparency, getUnnormalizedComponents, hasAlpha, isAlphaPremultiplied, isCompatibleRaster, isCompatibleSampleModel, toString`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### GrayscaleColorModel

    public GrayscaleColorModel(boolean zeroIsWhite)

  Constructs a GrayColorModel. Pixels described by this color model will all have alpha components of 255 (fully opaque). This colormodel is similar to IndexColorModel except the palette is fixed to scales of grey from black to white. This constructor set pixel size to 8 and color component arrays of size 256.
  Parameters:
    `zeroIsWhite` - Flag if set means that a pixel of value of 0 return the color white. Else value pixel value 0 returns black.

### GrayscaleColorModel

    public GrayscaleColorModel(boolean zeroIsWhite,
                               int pixelSize)

  Parameters:
    `zeroIsWhite` - Flag if set means that a pixel of value of 0 return the color white
    `pixelSize` - range of values 1 to 8 bits only.

Method Detail

### getZeroIsWhite

    public boolean getZeroIsWhite()

  Returns:
    the flag indicating if ZeroIsWhite for this ColorModel. If returns false then Zero is Black for this ColorModel.

### init

    protected void init(boolean zeroIsWhite)

  Parameters:
    `zeroIsWhite` - Flag if set means that a pixel of value of 0 return the color white transition between. If not set then colour transition reversed.

### getRed

    public int getRed(int pixel)

  Parameters:
    `pixel` - The pixel to lookup value for. For this colour model the pixel can only range between 0 and (2 ^ pixelDepth) - 1)
  Returns:
    the red color compoment for the specified pixel in the range 0-255.
  Overrides:
    getRed in class java.awt.image.ColorModel

### getGreen

    public int getGreen(int pixel)

  Parameters:
    `pixel` - The pixel to lookup value for. For this colour model the pixel can only range between 0 and 255.
  Returns:
    the green color compoment for the specified pixel in the range 0-255.
  Overrides:
    getGreen in class java.awt.image.ColorModel

### getBlue

    public int getBlue(int pixel)

  Parameters:
    `pixel` - The pixel to lookup value for. For this colour model the pixel can only range between 0 and 255.
  Returns:
    the blue color compoment for the specified pixel in the range 0-255.
  Overrides:
    getBlue in class java.awt.image.ColorModel

### getAlpha

    public int getAlpha(int pixel)

  Parameters:
    `pixel` - The pixel to lookup value for. For this colour model the pixel can only range between 0 and 255.
  Returns:
    the alpha compoment for the specified pixel in the range 0-255.
  Overrides:
    getAlpha in class java.awt.image.ColorModel

### getRGB

    public int getRGB(int pixel)

  Returns the color of the pixel in the default RGB color model.
  Overrides:
    getRGB in class java.awt.image.ColorModel
  See Also:
    `ColorModel.getRGBdefault()`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD