Copyright 2011-01-06 Werner Randelshofer

ch.randelshofer.gui.image
Class HAMColorModel

java.lang.Object
  extended by java.awt.image.ColorModel
      extended by java.awt.image.PackedColorModel
          extended by java.awt.image.DirectColorModel
              extended by ch.randelshofer.gui.image.HAMColorModel
All Implemented Interfaces:
java.awt.Transparency

public class HAMColorModel
extends java.awt.image.DirectColorModel

ColorModel for HAM compressed images.

Version:
1.1 2006-12-25 New constructor added.
1.0 1999-10-19
Author:
Werner Randelshofer, Hausmatt 10, CH-6405 Immensee, Switzerland

Field Summary
static int HAM6
           
static int HAM8
           
protected  int HAMType
           
protected  int map_size
           
protected  boolean opaque
           
protected  int[] rgb
           
 
Fields inherited from class java.awt.image.ColorModel
pixel_bits, transferType
 
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
 
Constructor Summary
HAMColorModel(int aHAMType, int size, byte[] r, byte[] g, byte[] b, boolean isOCS)
          Creates a new HAM Color model using the specified base colors.
HAMColorModel(int aHAMType, int size, int[] rgb, boolean isOCS)
          Creates a new HAM Color model using the specified base colors.
 
Method Summary
 void getBlues(byte[] b)
          Copies the array of blue color components into the given array.
 int getDepth()
          Returns the number of planes required to represent this HAMColorModel in a Bitmap.
 void getGreens(byte[] g)
          Copies the array of green color components into the given array.
 int getHAMType()
          Returns the HAM Type of this HAMColorModel: HAM8 or HAM6.
 int getMapSize()
          Returns the size of the color component arrays in this IndexColorModel.
 void getReds(byte[] r)
          Copies the array of red color components into the given array.
 void getRGBs(int[] rgbs)
          Copies the array of color components into the given array.
protected  void setRGBs(int size, byte[] r, byte[] g, byte[] b, byte[] a)
          Sets the HAM base colors.
 
Methods inherited from class java.awt.image.DirectColorModel
coerceData, createCompatibleWritableRaster, getAlpha, getAlpha, getAlphaMask, getBlue, getBlue, getBlueMask, getComponents, getComponents, getDataElement, getDataElements, getDataElements, getGreen, getGreen, getGreenMask, getRed, getRed, getRedMask, getRGB, getRGB, isCompatibleRaster, toString
 
Methods inherited from class java.awt.image.PackedColorModel
createCompatibleSampleModel, equals, getAlphaRaster, getMask, getMasks, isCompatibleSampleModel
 
Methods inherited from class java.awt.image.ColorModel
finalize, getColorSpace, getComponentSize, getComponentSize, getDataElement, getDataElements, getNormalizedComponents, getNormalizedComponents, getNumColorComponents, getNumComponents, getPixelSize, getRGBdefault, getTransferType, getTransparency, getUnnormalizedComponents, hasAlpha, hashCode, isAlphaPremultiplied
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

HAM6

public static final int HAM6
See Also:
Constant Field Values

HAM8

public static final int HAM8
See Also:
Constant Field Values

HAMType

protected int HAMType

map_size

protected int map_size

opaque

protected boolean opaque

rgb

protected int[] rgb
Constructor Detail

HAMColorModel

public HAMColorModel(int aHAMType,
                     int size,
                     byte[] r,
                     byte[] g,
                     byte[] b,
                     boolean isOCS)
Creates a new HAM Color model using the specified base colors.

Parameters:
aHAMType - Type, must be HAM6 or HAM 8.
size - The size of the color palette.
r - The red colors as 8 bit or as 4 bit values.
g - The green colors as 8 bit or as 4 bit values.
b - The blue colors as 8 bit or as 4 bit values.
isOCS - Set this to true if the colors are 4 bit values.

HAMColorModel

public HAMColorModel(int aHAMType,
                     int size,
                     int[] rgb,
                     boolean isOCS)
Creates a new HAM Color model using the specified base colors.

Parameters:
aHAMType - Type, must be HAM6 or HAM 8.
size - The size of the color palette.
rgb - The rgb colors.
isOCS - Set this to true if the colors are 12 bit precision only.
Method Detail

getHAMType

public int getHAMType()
Returns the HAM Type of this HAMColorModel: HAM8 or HAM6.


getDepth

public int getDepth()
Returns the number of planes required to represent this HAMColorModel in a Bitmap.


setRGBs

protected void setRGBs(int size,
                       byte[] r,
                       byte[] g,
                       byte[] b,
                       byte[] a)
Sets the HAM base colors.

Parameters:
size - The size of the color palette.
r - The red colors as 8 bit values.
g - The green colors as 8 bit values.
b - The blue colors as 8 bit values.
a - The alpha channels as 8 bit values.

getReds

public final void getReds(byte[] r)
Copies the array of red color components into the given array. Only the initial entries of the array as specified by getMapSize() are written.


getGreens

public final void getGreens(byte[] g)
Copies the array of green color components into the given array. Only the initial entries of the array as specified by getMapSize() are written.


getBlues

public final void getBlues(byte[] b)
Copies the array of blue color components into the given array. Only the initial entries of the array as specified by getMapSize() will be written.


getRGBs

public final void getRGBs(int[] rgbs)
Copies the array of color components into the given array. Only the initial entries of the array as specified by getMapSize() will be written.


getMapSize

public final int getMapSize()
Returns the size of the color component arrays in this IndexColorModel.


Copyright 2011-01-06 Werner Randelshofer