uk.ac.starlink.ttools.plot2.paper
Class RgbImage

java.lang.Object
  extended by uk.ac.starlink.ttools.plot2.paper.RgbImage

public class RgbImage
extends Object

An efficiently stored RGB or RGBA image backed by an int buffer. Each pixel is represented by a 4-byte int, with the three least-significant bytes giving 0-255 levels of red, green, blue (msb->lsb) and, optionally, the most significant byte giving alpha. This corresponds to the BufferedImage constants TYPE_INT_RGB and TYPE_INT_ARGB. The values in the buffer are therefore the same as those used by BufferedImage setRGB/getRGB, but can (presumably) be manipulated more efficiently by addressing the array here directly. These RGB values are also the same as those used by Compositor.

Note: in tests, painting a colour on the image's graphics context does not seem to give exactly the expected result in terms of ARGB values in the buffer, though it's not far off. See the RgbImageTest testcase for more discussion.

Since:
14 Feb 2013
Author:
Mark Taylor

Method Summary
static RgbImage createRgbImage(int width, int height, boolean hasAlpha)
          Constructs an RgbImage.
 int[] getBuffer()
          Returns the data as a modifiable int array.
 BufferedImage getImage()
          Returns the data as a BufferedImage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getImage

public BufferedImage getImage()
Returns the data as a BufferedImage.

Returns:
image

getBuffer

public int[] getBuffer()
Returns the data as a modifiable int array.

Returns:
int buffer

createRgbImage

public static RgbImage createRgbImage(int width,
                                      int height,
                                      boolean hasAlpha)
Constructs an RgbImage.

Parameters:
width - width in pixels
height - height in pixels
hasAlpha - true for ARGB, false for RGB


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.