# Class GreyImage

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

public class GreyImage extends Object
A greyscale image backed by a a byte buffer. The buffer is initially set to zero values, corresponding to black. White corresponds to byte values of 255. Trial and error suggests that it is more efficient in time, though not in memory, to use greyscale than bitmap images (BufferedImage.TYPE_BYTE_BINARY), even if only bitmap type values are required.

Since:
  26 Nov 2013
Author:
  Mark Taylor
See Also:
  - `GraphicsBitmap`
  - `RgbImage`

## Method Summary

Modifier and Type
Method
Description
`static GreyImage`
`createGreyImage(int width, int height)`
Factory method to create an instance.
`Pixer`
`createPixer()`
Returns a pixel iterator that iterates over all the pixels that have been altered (are non-white) in this image.
`byte[]`
`getBuffer()`
Returns the byte array backing the image.
`BufferedImage`
`getImage()`
Returns the greyscale image.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### getImage

public BufferedImage getImage()
Returns the greyscale image.

Returns:
  image

### getBuffer

public byte[] getBuffer()
Returns the byte array backing the image.

Returns:
  byte array

### createPixer

public Pixer createPixer()
Returns a pixel iterator that iterates over all the pixels that have been altered (are non-white) in this image. In the current implementation this is not efficient to be re-used.

Returns:
  iterator over non-white pixels

### createGreyImage

public static GreyImage createGreyImage(int width, int height)
Factory method to create an instance.

Parameters:
  `width` - image width in pixels
  `height` - image height in pixels