Class PixelImage
- java.lang.Object
-
- uk.ac.starlink.ttools.plot2.layer.PixelImage
-
public class PixelImage extends java.lang.ObjectAggregates information for painting a colour-mapped image.Some utility methods are provided for generating suitable colour models.
- Since:
- 4 Sep 2015
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Constructor Description PixelImage(java.awt.Dimension size, int[] pixels, java.awt.image.IndexColorModel colorModel)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.awt.image.IndexColorModelcreateColorModel(Shader shader, boolean zeroTransparent)Returns an indexed colour model whose entries range from one end to the other of a given shader object.static java.awt.image.IndexColorModelcreateMaskColorModel(java.awt.Color color)Returns a 2-colour indexed colour model.java.awt.image.IndexColorModelgetColorModel()Returns the colour model.int[]getPixels()Returns the pixel array.java.awt.DimensiongetSize()Returns the dimensions of this image.voidpaintPixels(java.awt.Graphics g, java.awt.Point origin)Paints this image to a given graphics context.voidpaintScaledPixels(java.awt.Graphics g, java.awt.Point origin, int scale)Paints this image to a given graphics context, with each pixel scaled by an integer factor.
-
-
-
Method Detail
-
getSize
public java.awt.Dimension getSize()
Returns the dimensions of this image.- Returns:
- size
-
getPixels
public int[] getPixels()
Returns the pixel array.- Returns:
- pixel array
-
getColorModel
public java.awt.image.IndexColorModel getColorModel()
Returns the colour model.- Returns:
- colour model
-
paintPixels
public void paintPixels(java.awt.Graphics g, java.awt.Point origin)Paints this image to a given graphics context.- Parameters:
g- graphics contextorigin- target position for origin of painted image
-
paintScaledPixels
public void paintScaledPixels(java.awt.Graphics g, java.awt.Point origin, int scale)Paints this image to a given graphics context, with each pixel scaled by an integer factor.- Parameters:
g- graphics contextorigin- target position for origin of painted imagescale- scaling factor
-
createColorModel
public static java.awt.image.IndexColorModel createColorModel(Shader shader, boolean zeroTransparent)
Returns an indexed colour model whose entries range from one end to the other of a given shader object.- Parameters:
shader- shader; should be absolutezeroTransparent- if true, the first entry in the returned colour map is transparent- Returns:
- colour model
-
createMaskColorModel
public static java.awt.image.IndexColorModel createMaskColorModel(java.awt.Color color)
Returns a 2-colour indexed colour model.- Parameters:
color- non-blank colour- Returns:
- colour map with two entries:
0=transparent, 1=
color
-
-