|
JIU 0.14.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.jiu.data.Palette
public class Palette
This class represents a palette, a list of RGB colors.
An RGB color here has three int values for its red, green and blue
intensity.
Each intensity value must be larger than or equal to zero and
smaller than or equal to the maximum intensity value that can be
given to the constructor Palette(int, int)
.
This maximum value is typically 255.
Note that the number of entries in a palette is restricted only
by the element index type int
so that palettes with
more than 256 entries are no problem.
When accessing (reading or writing) samples of this palette, use
the constants RGBIndex.INDEX_RED
, RGBIndex.INDEX_GREEN
and RGBIndex.INDEX_BLUE
of
this class to define a color channel.
PalettedImage
Field Summary |
---|
Fields inherited from interface net.sourceforge.jiu.data.RGBIndex |
---|
INDEX_BLUE, INDEX_GREEN, INDEX_RED |
Constructor Summary | |
---|---|
Palette(int numEntries)
Create a palette with the given number of entries and a maximum value of 255 . |
|
Palette(int numEntries,
int maxValue)
Create a palette with the given number of entries and a maximum value for each sample. |
Method Summary | |
---|---|
Object |
clone()
Creates a copy of this palette, allocating a new Palette object and copying each RGB triplet to the new palette. |
long |
getAllocatedMemory()
Returns the amount of memory in bytes allocated for this palette. |
int |
getMaxValue()
Returns the maximum value allowed for a sample. |
int |
getNumEntries()
Returns the number of entries in this palette. |
int |
getSample(int channelIndex,
int entryIndex)
Returns one of the samples of this palette. |
int[] |
getSamples(int channelIndex)
Returns all samples of one channel as an int array. |
boolean |
isBlackAndWhite()
Checks if all entries of this palette are either black or white. |
boolean |
isGray()
Checks if this palette is gray, i.e., checks if all entries are gray. |
void |
put(int entryIndex,
int red,
int green,
int blue)
|
void |
putSample(int channelIndex,
int entryIndex,
int newValue)
Sets one sample of one color entry in the palette to a new value. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Palette(int numEntries, int maxValue)
numEntries
- the number of entries to be accessible in this palettemaxValue
- the maximum value to be allowed for each samplepublic Palette(int numEntries)
255
.
numEntries
- the number of entries to be accessible in this paletteMethod Detail |
---|
public Object clone()
clone
in class Object
public long getAllocatedMemory()
public int getMaxValue()
public int getNumEntries()
public int getSample(int channelIndex, int entryIndex)
entryIndex
- the index of the color to be addressed, must be from
0
to getNumEntries() - 1
channelIndex
- one of the three channels; must be RGBIndex.INDEX_RED
,
RGBIndex.INDEX_GREEN
or RGBIndex.INDEX_BLUE
public int[] getSamples(int channelIndex)
channelIndex
- index of the channel, one of the RGBIndex
constants
public boolean isBlackAndWhite()
0
, it is white if they are all equal to
getMaxValue()
.
No particular order of entries (e.g. first color black, second white)
is demanded and no specific number of entries (e.g. 2).
This means that a palette is black and white if it contains ten entries
that are all black.
public boolean isGray()
public void put(int entryIndex, int red, int green, int blue)
public void putSample(int channelIndex, int entryIndex, int newValue)
channelIndex
-
|
JIU 0.14.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |