Class RgbImage
- java.lang.Object
-
- uk.ac.starlink.ttools.plot2.paper.RgbImage
-
public class RgbImage extends java.lang.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 theBufferedImage
constantsTYPE_INT_RGB
andTYPE_INT_ARGB
. The values in the buffer are therefore the same as those used byBufferedImage
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 byCompositor
.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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RgbImage
createRgbImage(int width, int height, boolean hasAlpha)
Constructs an RgbImage.int[]
getBuffer()
Returns the data as a modifiable int array.java.awt.image.BufferedImage
getImage()
Returns the data as a BufferedImage.
-
-
-
Method Detail
-
getImage
public java.awt.image.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 pixelsheight
- height in pixelshasAlpha
- true for ARGB, false for RGB
-
-