Class GraphicUtils
java.lang.Object
net.mtrop.doom.util.GraphicUtils
Graphics utility methods for image types.
- Author:
- Matthew Tropiano
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Colormap[]createColormapsFromGraphic(GraphicObject graphic) Creates a series of colormaps using a two-dimensional graphic, assumed indexed.static FlatcreateFlat(BufferedImage image, Palette palette) Creates aFlatfrom aBufferedImage.static FlatcreateFlat(BufferedImage image, Palette palette, Colormap colormap) Creates aFlatfrom aBufferedImage.static FlatcreateFlat(PNGPicture pngPicture, Palette palette) Creates aFlatfrom aPNGPicture.static FlatcreateFlat(PNGPicture pngPicture, Palette palette, Colormap colormap) Creates aFlatfrom aPNGPicture.static BufferedImagecreateImage(Flat flat, Palette palette) Creates aBufferedImagefrom aFlat.static BufferedImagecreateImage(Flat flat, Palette palette, Colormap colormap) Creates aBufferedImagefrom aFlat.static BufferedImagecreateImage(Picture picture, Palette palette) Creates aBufferedImagefrom aPicture.static BufferedImagecreateImage(Picture picture, Palette palette, Colormap colormap) Creates aBufferedImagefrom aFlat.static BufferedImagecreateImageForEndDoom(EndDoom endoom, boolean blinking) Returns the EndDoom data rendered to a BufferedImage.static PicturecreatePicture(BufferedImage image, Palette palette) Creates aPicturefrom aBufferedImage.static PicturecreatePicture(BufferedImage image, Palette palette, Colormap colormap) Creates aPicturefrom aBufferedImage.static PicturecreatePicture(PNGPicture pngPicture, Palette palette) Creates aPicturefrom aBufferedImage.static PicturecreatePicture(PNGPicture pngPicture, Palette palette, Colormap colormap) Creates aPicturefrom aBufferedImage.static PNGPicturecreatePNGImage(Picture picture, Palette palette) Creates aPNGPicturefrom aPicture.static PNGPicturecreatePNGImage(Picture picture, Palette palette, Colormap colormap) Creates aPNGPicturefrom aPicture.static voidsetColormap(Colormap colormap, Palette target, Palette sampled) Sets the indices of aColormapby attempting to match colors in a palette from other colors in a different palette.
-
Field Details
-
DOOM
Default Doom palette. -
HERETIC
Default Heretic palette. -
HEXEN
Default Hexen palette. -
STRIFE
Default Strife palette. -
ANSI_COLORS
ANSI color table.
-
-
Method Details
-
createFlat
Creates aFlatfrom aBufferedImage. Colors are approximated using the providedPalette, and translated using the providedColormap. Pixels that are not fully opaque are given index 0.- Parameters:
image- the image to convert.palette- the palette to use for color approximation.- Returns:
- the resultant Flat.
-
createFlat
Creates aFlatfrom aBufferedImage. Colors are approximated using the providedPalette, and translated using the providedColormap. Pixels that are not fully opaque are given index 0.- Parameters:
image- the image to convert.palette- the palette to use for color approximation.colormap- the colormap to use for palette translation. Can benullfor no translation.- Returns:
- the resultant Flat.
-
createPicture
Creates aPicturefrom aBufferedImage. Colors are approximated using the providedPalette, and translated using the providedColormap. Pixels that are not fully opaque are considered transparent.- Parameters:
image- the image to convert.palette- the palette to use for color approximation.- Returns:
- the resultant Picture.
-
createPicture
Creates aPicturefrom aBufferedImage. Colors are approximated using the providedPalette, and translated using the providedColormap. Pixels that are not fully opaque are considered transparent.- Parameters:
image- the image to convert.palette- the palette to use for color approximation.colormap- the colormap to use for palette translation. Can benullfor no translation.- Returns:
- the resultant Picture.
-
createFlat
Creates aFlatfrom aPNGPicture. Colors are approximated using the providedPalette, and translated using the providedColormap. Pixels that are not fully opaque are given index 0.- Parameters:
pngPicture- the PNGPicture to convert.palette- the palette to use for color approximation.- Returns:
- the resultant Flat.
- Since:
- 2.13.0
-
createFlat
Creates aFlatfrom aPNGPicture. Colors are approximated using the providedPalette, and translated using the providedColormap. Pixels that are not fully opaque are given index 0.- Parameters:
pngPicture- the PNGPicture to convert.palette- the palette to use for color approximation.colormap- the colormap to use for palette translation. Can benullfor no translation.- Returns:
- the resultant Flat.
- Since:
- 2.13.0
-
createPicture
Creates aPicturefrom aBufferedImage. Colors are approximated using the providedPalette, and translated using the providedColormap. Pixels that are not fully opaque are considered transparent. Offset info from the PNG is preserved.- Parameters:
pngPicture- the PNGPicture to convert.palette- the palette to use for color approximation.- Returns:
- the resultant Picture.
- Since:
- 2.13.0
-
createPicture
Creates aPicturefrom aBufferedImage. Colors are approximated using the providedPalette, and translated using the providedColormap. Pixels that are not fully opaque are considered transparent. Offset info from the PNG is preserved.- Parameters:
pngPicture- the PNGPicture to convert.palette- the palette to use for color approximation.colormap- the colormap to use for palette translation. Can benullfor no translation.- Returns:
- the resultant Picture.
- Since:
- 2.13.0
-
createImage
Creates aBufferedImagefrom aFlat.- Parameters:
flat- the Flat to convert.palette- the palette to use as a color source.- Returns:
- a full color image of the indexed-color Flat.
-
createImage
Creates aBufferedImagefrom aFlat.- Parameters:
flat- the Flat to convert.palette- the palette to use as a color source.colormap- the colormap for palette translation, if any. Can be null for no translation.- Returns:
- a full color image of the indexed-color Flat.
-
createImage
Creates aBufferedImagefrom aPicture.- Parameters:
picture- the Picture to convert.palette- the palette to use as a color source.- Returns:
- a full color image of the indexed-color Flat.
-
createImage
Creates aBufferedImagefrom aFlat.- Parameters:
picture- the Picture to convert.palette- the palette to use as a color source.colormap- the colormap for palette translation, if any. Can be null for no translation.- Returns:
- a full color image of the indexed-color Flat.
-
createPNGImage
Creates aPNGPicturefrom aPicture.- Parameters:
picture- the Picture to convert.palette- the palette to use as a color source.- Returns:
- a full color image of the indexed-color Flat.
-
createPNGImage
Creates aPNGPicturefrom aPicture.- Parameters:
picture- the Picture to convert.palette- the palette to use as a color source.colormap- the colormap for palette translation, if any. Can be null for no translation.- Returns:
- a full color image of the indexed-color Flat.
-
createImageForEndDoom
Returns the EndDoom data rendered to a BufferedImage.- Parameters:
endoom- the EndDoom lump to render.blinking- if true, this will render the "blinking" characters.- Returns:
- a BufferedImage that represents the graphic image in RGB color (including transparency).
- Throws:
NullPointerException- if endoom is null.
-
setColormap
Sets the indices of aColormapby attempting to match colors in a palette from other colors in a different palette.This is a convenience for:
for (int i = 0; i < Colormap.NUM_INDICES; i++) colormap.setPaletteIndex(i, target.getNearestColorIndex(sampled.getColorARGB(i)))- Parameters:
colormap- the colormap to set.target- the palette to match against.sampled- the palette to sample from for matching.- Since:
- 2.2.0
-
createColormapsFromGraphic
Creates a series of colormaps using a two-dimensional graphic, assumed indexed. The provided indexed graphic must have a width of at leastColormap.NUM_INDICES. The amount of colormaps returned is equal to the graphic height. Translucent pixels are changed to index 0.- Parameters:
graphic- the source graphic to use.- Returns:
- an array of new colormaps.
- Throws:
NullPointerException- if graphic is null.ArrayIndexOutOfBoundsException- if the provided graphic's width is less thanColormap.NUM_INDICES.- Since:
- 2.2.0
-