java.awt.image
Class IndexColorModel
- Transparency
Color model similar to pseudo visual in X11.
This color model maps linear pixel values to actual RGB and alpha colors.
Thus, pixel values are indexes into the color map. Each color component is
an 8-bit unsigned value.
The
IndexColorModel
supports a map of valid pixels, allowing
the representation of holes in the the color map. The valid map is
represented as a
BigInteger
where each bit indicates the validity
of the map entry with the same index.
Colors can have alpha components for transparency support. If alpha
component values aren't given, color values are opaque. The model also
supports a reserved pixel value to represent completely transparent colors,
no matter what the actual color component values are.
IndexColorModel
supports anywhere from 1 to 16 bit index
values. The allowed transfer types are
DataBuffer.TYPE_BYTE
and
DataBuffer.TYPE_USHORT
.
IndexColorModel(int bits, int size, byte[] reds, byte[] greens, byte[] blues) - Creates a new indexed color model for
size color elements
with no alpha component.
|
IndexColorModel(int bits, int size, byte[] reds, byte[] greens, byte[] blues, byte[] alphas) - Creates a new indexed color model for
size color elements
including alpha.
|
IndexColorModel(int bits, int size, byte[] reds, byte[] greens, byte[] blues, int trans) - Creates a new indexed color model for
size color elements.
|
IndexColorModel(int bits, int size, byte[] cmap, int start, boolean hasAlpha) - Creates a new indexed color model using the color components in
cmap .
|
IndexColorModel(int bits, int size, byte[] cmap, int start, boolean hasAlpha, int trans) - Construct an IndexColorModel from an array of red, green, blue, and
optional alpha components.
|
IndexColorModel(int bits, int size, int[] cmap, int start, boolean hasAlpha, int trans, int transferType) - Construct an IndexColorModel from an array of
size packed
colors.
|
IndexColorModel(int bits, int size, int[] cmap, int start, int transferType, BigInteger validBits) - Construct an IndexColorModel using a colormap with holes.
|
BufferedImage | convertToIntDiscrete(Raster raster, boolean forceARGB) - Construct a
BufferedImage with rgb pixel values from a
Raster .
|
SampleModel | createCompatibleSampleModel(int w, int h) - Creates a
SampleModel that is compatible to this color model.
|
int | getAlpha(int pixel) - Returns the alpha component of the color in the lookup table for the
given pixel value.
|
void | getAlphas(byte[] a) - Fills the supplied array with the alpha component of each color in the
lookup table.
|
int | getBlue(int pixel) - Returns the blue component of the color in the lookup table for the
given pixel value.
|
void | getBlues(byte[] b) - Fills the supplied array with the blue component of each color in the
lookup table.
|
int | getGreen(int pixel) - Returns the green component of the color in the lookup table for the
given pixel value.
|
void | getGreens(byte[] g) - Fills the supplied array with the green component of each color in the
lookup table.
|
int | getMapSize() - Returns the size of the color lookup table.
|
int | getRGB(int pixel) - Get the RGB color value of the given pixel using the default
RGB color model.
|
void | getRGBs(int[] rgb) - Get the RGB color values of all pixels in the map using the default
RGB color model.
|
int | getRed(int pixel) - Returns the red component of the color in the lookup table for the
given pixel value.
|
void | getReds(byte[] r) - Fills the supplied array with the red component of each color in the
lookup table.
|
int | getTransparentPixel() - Get the index of the transparent color in this color model.
|
BigInteger | getValidPixels() - Returns a binary value (
BigInteger ) where each bit represents an
entry in the color lookup table.
|
boolean | isValid() - Return
true if all pixels are valid, false
otherwise.
|
boolean | isValid(int pixel) - Return
true if the lookup table contains valid data for
pixel , and false otherwise.
|
coerceData , coerceDataWorker , createCompatibleSampleModel , createCompatibleWritableRaster , equals , finalize , getAlpha , getAlpha , getAlphaRaster , getBlue , getBlue , getColorSpace , getComponentSize , getComponentSize , getComponents , getComponents , getDataElement , getDataElement , getDataElements , getDataElements , getDataElements , getGreen , getGreen , getNormalizedComponents , getNormalizedComponents , getNumColorComponents , getNumComponents , getPixelSize , getRGB , getRGB , getRGBdefault , getRed , getRed , getTransferType , getTransparency , getUnnormalizedComponents , hasAlpha , isAlphaPremultiplied , isCompatibleRaster , isCompatibleSampleModel , toString |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
IndexColorModel
public IndexColorModel(int bits,
int size,
byte[] reds,
byte[] greens,
byte[] blues)
Creates a new indexed color model for size
color elements
with no alpha component. Each array must contain at least
size
elements. For each array, the i-th color is described
by reds[i], greens[i] and blues[i].
bits
- the number of bits needed to represent size
colors.size
- the number of colors in the color map.reds
- the red component of all colors.greens
- the green component of all colors.blues
- the blue component of all colors.
IndexColorModel
public IndexColorModel(int bits,
int size,
byte[] reds,
byte[] greens,
byte[] blues,
byte[] alphas)
Creates a new indexed color model for size
color elements
including alpha. Each array must contain at least size
elements. For each array, the i-th color is described
by reds[i], greens[i], blues[i] and alphas[i].
bits
- the number of bits needed to represent size
colors.size
- the number of colors in the color map.reds
- the red component of all colors.greens
- the green component of all colors.blues
- the blue component of all colors.alphas
- the alpha component of all colors (null
permitted).
IndexColorModel
public IndexColorModel(int bits,
int size,
byte[] reds,
byte[] greens,
byte[] blues,
int trans)
Creates a new indexed color model for size
color elements.
Each array must contain at least size
elements. For each
array, the i-th color is described by reds[i], greens[i] and blues[i].
All the colors are opaque except for the transparent color.
bits
- the number of bits needed to represent size
colorssize
- the number of colors in the color mapreds
- the red component of all colorsgreens
- the green component of all colorsblues
- the blue component of all colorstrans
- the index of the transparent color (use -1 for no
transparent color).
IndexColorModel
public IndexColorModel(int bits,
int size,
byte[] cmap,
int start,
boolean hasAlpha)
Creates a new indexed color model using the color components in
cmap
. If hasAlpha
is true
then
cmap
contains an alpha component after each of the red, green
and blue components.
bits
- the number of bits needed to represent size
colorssize
- the number of colors in the color mapcmap
- packed color componentsstart
- the offset of the first color component in cmap
hasAlpha
- cmap
has alpha values
IndexColorModel
public IndexColorModel(int bits,
int size,
byte[] cmap,
int start,
boolean hasAlpha,
int trans)
Construct an IndexColorModel from an array of red, green, blue, and
optional alpha components. The component values are interleaved as RGB(A).
bits
- the number of bits needed to represent size
colorssize
- the number of colors in the color mapcmap
- interleaved color componentsstart
- the offset of the first color component in cmap
hasAlpha
- cmap
has alpha valuestrans
- the index of the transparent color
IndexColorModel
public IndexColorModel(int bits,
int size,
int[] cmap,
int start,
boolean hasAlpha,
int trans,
int transferType)
Construct an IndexColorModel from an array of size
packed
colors. Each int element contains 8-bit red, green, blue, and optional
alpha values packed in order. If hasAlpha is false, then all the colors
are opaque except for the transparent color.
bits
- the number of bits needed to represent size
colorssize
- the number of colors in the color mapcmap
- packed color componentsstart
- the offset of the first color component in cmap
hasAlpha
- cmap
has alpha valuestrans
- the index of the transparent colortransferType
- DataBuffer.TYPE_BYTE
or
DataBuffer.TYPE_USHORT
.
IndexColorModel
public IndexColorModel(int bits,
int size,
int[] cmap,
int start,
int transferType,
BigInteger validBits)
Construct an IndexColorModel using a colormap with holes.
The IndexColorModel is built from the array of ints defining the
colormap. Each element contains red, green, blue, and alpha
components. The ColorSpace is sRGB. The transparency value is
automatically determined.
This constructor permits indicating which colormap entries are valid,
using the validBits argument. Each entry in cmap is valid if the
corresponding bit in validBits is set.
bits
- the number of bits needed to represent size
colors.size
- the number of colors in the color map.cmap
- packed color components.start
- the offset of the first color component in cmap
.transferType
- DataBuffer.TYPE_BYTE
or
DataBuffer.TYPE_USHORT
.validBits
- a map of the valid entries in cmap
.
convertToIntDiscrete
public BufferedImage convertToIntDiscrete(Raster raster,
boolean forceARGB)
Construct a
BufferedImage
with rgb pixel values from a
Raster
.
Constructs a new BufferedImage in which each pixel is an RGBA int from
a Raster with index-valued pixels. If this model has no alpha component
or transparent pixel, the type of the new BufferedImage is TYPE_INT_RGB.
Otherwise the type is TYPE_INT_ARGB. If forceARGB is true, the type is
forced to be TYPE_INT_ARGB no matter what.
raster
- The source of pixel values.forceARGB
- True if type must be TYPE_INT_ARGB.
- New BufferedImage with RBGA int pixel values.
getAlpha
public final int getAlpha(int pixel)
Returns the alpha component of the color in the lookup table for the
given pixel value. If no alpha channel was specified when the color model
was created, then 255 is returned for all pixels except the transparent
pixel (if one is defined - see
getTransparentPixel()
) which
returns an alpha of 0.
- getAlpha in interface ColorModel
pixel
- the pixel lookup value.
- The alpha component of the color in the lookup table (in the
range 0 to 255).
getAlphas
public final void getAlphas(byte[] a)
Fills the supplied array with the alpha component of each color in the
lookup table. If the model has a transparent pixel specified, the alpha
for that pixel will be 0.
getBlue
public final int getBlue(int pixel)
Returns the blue component of the color in the lookup table for the
given pixel value.
- getBlue in interface ColorModel
pixel
- the pixel lookup value.
- The blue component of the color in the lookup table.
getBlues
public final void getBlues(byte[] b)
Fills the supplied array with the blue component of each color in the
lookup table.
getGreen
public final int getGreen(int pixel)
Returns the green component of the color in the lookup table for the
given pixel value.
- getGreen in interface ColorModel
pixel
- the pixel lookup value.
- The green component of the color in the lookup table.
getGreens
public final void getGreens(byte[] g)
Fills the supplied array with the green component of each color in the
lookup table.
getMapSize
public final int getMapSize()
Returns the size of the color lookup table.
- The size of the color lookup table.
getRGB
public final int getRGB(int pixel)
Get the RGB color value of the given pixel using the default
RGB color model.
- getRGB in interface ColorModel
pixel
- the pixel lookup value.
getRGBs
public final void getRGBs(int[] rgb)
Get the RGB color values of all pixels in the map using the default
RGB color model.
rgb
- The destination array.
getRed
public final int getRed(int pixel)
Returns the red component of the color in the lookup table for the
given pixel value.
- getRed in interface ColorModel
pixel
- the pixel lookup value.
- The red component of the color in the lookup table.
getReds
public final void getReds(byte[] r)
Fills the supplied array with the red component of each color in the
lookup table.
getTransparentPixel
public final int getTransparentPixel()
Get the index of the transparent color in this color model.
- The index of the color that is considered transparent, or -1 if
there is no transparent color.
getValidPixels
public BigInteger getValidPixels()
Returns a binary value (
BigInteger
) where each bit represents an
entry in the color lookup table. If the bit is on, the entry is valid.
isValid
public boolean isValid()
Return true
if all pixels are valid, false
otherwise.
true
if all pixels are valid, false
otherwise.
isValid
public boolean isValid(int pixel)
Return true
if the lookup table contains valid data for
pixel
, and false
otherwise.
pixel
- the pixel value used to index the color lookup table.
true
if pixel
is valid,
false
otherwise.
IndexColorModel.java -- Java class for interpreting Pixel objects
Copyright (C) 1999, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.