Class Colormap
java.lang.Object
net.mtrop.doom.graphics.Colormap
- All Implemented Interfaces:
BinaryObject
This is a single entry that indexes the palette indices for color lookup.
The COLORMAP lump contains several of these.
Other commercial IWAD lumps that are colormaps or contain many colormaps are the TRANTBL lumps in Hexen and TINTTAB.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.mtrop.doom.object.BinaryObject
BinaryObject.InlineScanner<BO extends BinaryObject>, BinaryObject.Reflect, BinaryObject.Scanner<BO extends BinaryObject>, BinaryObject.Shared, BinaryObject.Transformer<BO extends BinaryObject> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int[]The index list in this map.static final intA single colormap's length in bytes.static final intThe number of total indices in a standard Doom color map. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a new colormap by copying the contents of this one.static ColormapCreates a color map where each color is mapped to its own index (index 0 is palette color 0 ...intgetPaletteIndex(int index) Returns the palette index of a specific index in the map.voidreadBytes(InputStream in) Reads from anInputStreamand sets this object's fields.Resets the color map to where each color is mapped to its own index (index 0 is palette color 0 ...setPaletteIndex(int index, int paletteIndex) Sets the palette index of a specific index in the map.setTranslation(int startIndex, int endIndex, int startValue, int endValue) Sets a colormap translation by remapping groups of contiguous indices.toString()voidwriteBytes(OutputStream out) Writes this object to anOutputStream.
-
Field Details
-
LENGTH
public static final int LENGTHA single colormap's length in bytes.- See Also:
-
NUM_INDICES
public static final int NUM_INDICESThe number of total indices in a standard Doom color map.- See Also:
-
indices
protected int[] indicesThe index list in this map.
-
-
Constructor Details
-
Colormap
public Colormap()Creates a new identity colormap where all indices point to their own index. -
Colormap
Creates a new colormap by copying the contents of another.- Parameters:
map- the source map to copy.
-
-
Method Details
-
createIdentityMap
Creates a color map where each color is mapped to its own index (index 0 is palette color 0 ... index 255 is palette color 255).- Returns:
- a new color map with the specified indices already mapped.
-
setIdentity
Resets the color map to where each color is mapped to its own index (index 0 is palette color 0 ... index 255 is palette color 255).- Returns:
- itself, to chain colormap calls.
-
setTranslation
Sets a colormap translation by remapping groups of contiguous indices.- Parameters:
startIndex- the starting replacement index (inclusive).endIndex- the ending replacement index (inclusive).startValue- the starting replacement value (inclusive).endValue- the ending replacement value (inclusive).- Returns:
- itself, to chain colormap calls.
-
copy
Creates a new colormap by copying the contents of this one.- Returns:
- itself, to chain colormap calls.
-
getPaletteIndex
public int getPaletteIndex(int index) Returns the palette index of a specific index in the map.- Parameters:
index- the index number of the entry.- Returns:
- the corresponding palette index.
- Throws:
ArrayIndexOutOfBoundsException- if index is greater than NUM_INDICES or less than 0.
-
setPaletteIndex
Sets the palette index of a specific index in the map.- Parameters:
index- the index number of the entry.paletteIndex- the new index.- Returns:
- itself, to chain colormap calls.
- Throws:
ArrayIndexOutOfBoundsException- if index is greater than 255 or less than 0.IllegalArgumentException- if paletteIndex is less than 0 or greater than 255.
-
readBytes
Description copied from interface:BinaryObjectReads from anInputStreamand sets this object's fields. Only reads the amount of bytes that it takes to read a single instance of the object. Note that not every object may have a consistent length!- Specified by:
readBytesin interfaceBinaryObject- Parameters:
in- theInputStreamto read from.- Throws:
IOException- if a read error occurs.
-
writeBytes
Description copied from interface:BinaryObjectWrites this object to anOutputStream.- Specified by:
writeBytesin interfaceBinaryObject- Parameters:
out- theOutputStreamto write to.- Throws:
IOException- if a write error occurs.
-
toString
-