public class ImageBytes
extends java.lang.Object
java.nio.ByteBuffer
; the pixel
array dimensions are W x H (x 4 bytes-per-pixel), with the origin
at the BOTTOM-LEFT, as required by OpenGL.Modifier and Type | Field and Description |
---|---|
int |
H
Image height in pixels
|
java.nio.ByteBuffer |
IMG_BYTE_BUFFER
|
int |
W
Image width in pixels
|
Constructor and Description |
---|
ImageBytes(java.awt.image.BufferedImage bimg)
Constructor, taking data from a BufferedImage.
|
ImageBytes(java.awt.image.BufferedImage bimg,
boolean israwRGBA,
boolean vflippedbimg)
Constructor taking its data from a BufferedImage, whose pixel
data may be in raw (RGBA) form or in BGRA form (Java
TYPE_INT_ARGB) as indicated by
israwRGBA , and which may
already be vertically flipped as indicated by vflippedbimg . |
ImageBytes(int w,
int h,
byte[] imgbytes)
Basic constructor, taking image data from an array.
|
ImageBytes(JAInputStream jins,
boolean COMPRESSED,
boolean IS_V22)
Image-bytes constructor that takes the image data
directly from the specified stream; this data
may or may not be compressed, as indicated by
COMPRESSED ,
and may be in v2.1 or v2.1 avatar definition format, as specified
by IS_V22 . |
Modifier and Type | Method and Description |
---|---|
void |
save(JAOutputStream jouts,
boolean compress)
Saves this image on the given JA output-stream (in v2.2
avatar definition format), compressed or uncompressed
as specified.
|
void |
saveAsPNG(JAOutputStream jouts,
boolean vflippng)
Saves this image in PNG format on the specified output stream,
vertically flipped if
vflippng is true. |
void |
saveAsPNG(java.lang.String outfile,
boolean vflippng)
Saves this image in PNG format on the specified file, vertically
flipped if
vflippng is true. |
void |
writeToStream(JAOutputStream jouts,
boolean pfxbcount)
Writes this image's data on the given output stream, with or
without an image byte-count prefix, as specified.
|
public final int W
public final int H
public final java.nio.ByteBuffer IMG_BYTE_BUFFER
public ImageBytes(int w, int h, byte[] imgbytes)
public ImageBytes(java.awt.image.BufferedImage bimg)
public ImageBytes(java.awt.image.BufferedImage bimg, boolean israwRGBA, boolean vflippedbimg)
israwRGBA
, and which may
already be vertically flipped as indicated by vflippedbimg
.public ImageBytes(JAInputStream jins, boolean COMPRESSED, boolean IS_V22) throws java.io.IOException
COMPRESSED
,
and may be in v2.1 or v2.1 avatar definition format, as specified
by IS_V22
.
In both v2.1 and v2.2 format the image data itself consists of
two integers, giving the image
width, W
, and height, H
, in pixels,
followed by N = W * H * 4
image bytes themselves
(4 bytes per pixel, in the order RGBA).
In the input stream the data may or may not be
compressed, as determined by the relevant flag byte.
N
, the number of image bytes, followed by the image data
as described above.2 * 4 + N
), followed by the image data itself.java.io.IOException
public void save(JAOutputStream jouts, boolean compress) throws java.io.IOException
java.io.IOException
public void writeToStream(JAOutputStream jouts, boolean pfxbcount) throws java.io.IOException
java.io.IOException
public void saveAsPNG(java.lang.String outfile, boolean vflippng) throws java.io.IOException
vflippng
is true.java.io.IOException
public void saveAsPNG(JAOutputStream jouts, boolean vflippng) throws java.io.IOException
vflippng
is true.java.io.IOException