ImageDatapublic final class ImageData extends Object implements AbstractImageDataAbstractImageData implementation based
on putpixel graphics library and stores data on Java heap. |
Fields Summary |
---|
private int | widthThe width, height of this Image | private int | height | private boolean | isMutableIf this Image is mutable. | private byte[] | pixelDataImage pixel data byte array.
If this is null, use nativePixelData and nativeAlphaData instead. | private byte[] | alphaDataImage alpha data byte array.
If pixelData is null, use nativePixelData instead. | private int | nativePixelDataImage native romized pixel data.
Set in native by loadRomizedImage().
Must remain 0 unless pixelData is null. | private int | nativeAlphaDataImage native romized alpha data.
Set in native by loadRomizedImage().
Must remain 0 unless pixelData is null. |
Constructors Summary |
---|
ImageData()Constructs empty ImageData .
| ImageData(int width, int height, boolean isMutable, boolean clearPixelData, boolean allocateAlpha)Constructs ImageData using passed in width and height.
Alpha array is allocated if allocateAlpha is true.
initImageData(width, height, isMutable, allocateAlpha);
if (clearPixelData) {
for (int i = 0; i < pixelData.length; i++) {
pixelData[i] = (byte)0xFF;
}
}
| ImageData(int width, int height, boolean isMutable, byte[] pixelData)Constructs mutable or immutable ImageData
using passed in width, height and pixel data.
this.width = width;
this.height = height;
this.isMutable = isMutable;
int length = width * height * 2;
byte[] newPixelData = new byte[length];
System.arraycopy(pixelData, 0, newPixelData, 0, length);
this.pixelData = newPixelData;
|
Methods Summary |
---|
public int | getHeight()Gets the height of the image in pixels. The value returned
must reflect the actual height of the image when rendered.
return height;
| byte[] | getPixelData()Gets pixel data associated with this ImageData instance.
return pixelData;
| public int | getWidth()Gets the width of the image in pixels. The value returned
must reflect the actual width of the image when rendered.
return width;
| public boolean | hasAlpha()Returns true if ImageData contains alpha data.
return (alphaData != null || nativeAlphaData != 0);
| void | initImageData(int width, int height, boolean isMutable, boolean allocateAlpha)Initializes mutable or immutable ImageData
using passed in width, height.
Alpha array is allocated if allocateAlpha is true.
this.width = width;
this.height = height;
this.isMutable = isMutable;
pixelData = new byte[width * height * 2];
if (allocateAlpha) {
alphaData = new byte[width * height];
} else {
alphaData = null;
}
| public boolean | isMutable()Check if this image is mutable. Mutable images can be modified by
rendering to them through a Graphics object
obtained from the
getGraphics() method of this object.
return isMutable;
| public void | removeAlpha()Removes alpha data information
alphaData = null;
|
|