Class PixelImage

java.lang.Object
uk.ac.starlink.ttools.plot2.layer.PixelImage

public class PixelImage extends Object
Aggregates 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 Details

    • PixelImage

      public PixelImage(Dimension size, int[] pixels, IndexColorModel colorModel)
      Constructor.
      Parameters:
      size - dimensions of the image
      pixels - pixel array, fits size all values must fall in range of colour model
      colorModel - indexed colour model
  • Method Details

    • getSize

      public Dimension getSize()
      Returns the dimensions of this image.
      Returns:
      size
    • getPixels

      public int[] getPixels()
      Returns the pixel array.
      Returns:
      pixel array
    • getColorModel

      public IndexColorModel getColorModel()
      Returns the colour model.
      Returns:
      colour model
    • paintPixels

      public void paintPixels(Graphics g, Point origin)
      Paints this image to a given graphics context.
      Parameters:
      g - graphics context
      origin - target position for origin of painted image
    • paintScaledPixels

      public void paintScaledPixels(Graphics g, Point origin, int scale)
      Paints this image to a given graphics context, with each pixel scaled by an integer factor.
      Parameters:
      g - graphics context
      origin - target position for origin of painted image
      scale - scaling factor
    • createColorModel

      public static 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 absolute
      zeroTransparent - if true, the first entry in the returned colour map is transparent
      Returns:
      colour model
    • createMaskColorModel

      public static IndexColorModel createMaskColorModel(Color color)
      Returns a 2-colour indexed colour model.
      Parameters:
      color - non-blank colour
      Returns:
      colour map with two entries: 0=transparent, 1=color