jarp
Class ImageBytes

java.lang.Object
  extended by jarp.ImageBytes

public class ImageBytes
extends java.lang.Object

Basic data for a rectangular array of (RGBA) pixel data held as a byte-array, wrapped in a direct 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.


Field Summary
 int H
          Image height in pixels
 java.nio.ByteBuffer IMG_BYTE_BUFFER
          Image bytes buffer: W x H groups of 4 (0123-->RGBA, the little-endian integer ABGR).
 int W
          Image width in pixels
 
Constructor Summary
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.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

W

public final int W
Image width in pixels


H

public final int H
Image height in pixels


IMG_BYTE_BUFFER

public final java.nio.ByteBuffer IMG_BYTE_BUFFER
Image bytes buffer: W x H groups of 4 (0123-->RGBA, the little-endian integer ABGR).

Constructor Detail

ImageBytes

public ImageBytes(int w,
                  int h,
                  byte[] imgbytes)
Basic constructor, taking image data from an array.


ImageBytes

public ImageBytes(java.awt.image.BufferedImage bimg)
Constructor, taking data from a BufferedImage.


ImageBytes

public 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

public ImageBytes(JAInputStream jins,
                  boolean COMPRESSED,
                  boolean IS_V22)
           throws java.io.IOException
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.

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.

Image Data Format for Avatar Definition Version 2.1

Image Data Format for Avatar Definition Version 2.2

Throws:
java.io.IOException
Method Detail

save

public void save(JAOutputStream jouts,
                 boolean compress)
          throws java.io.IOException
Saves this image on the given JA output-stream (in v2.2 avatar definition format), compressed or uncompressed as specified.

Throws:
java.io.IOException

writeToStream

public void writeToStream(JAOutputStream jouts,
                          boolean pfxbcount)
                   throws java.io.IOException
Writes this image's data on the given output stream, with or without an image byte-count prefix, as specified.

Throws:
java.io.IOException

saveAsPNG

public void saveAsPNG(java.lang.String outfile,
                      boolean vflippng)
               throws java.io.IOException
Saves this image in PNG format on the specified file, vertically flipped if vflippng is true.

Throws:
java.io.IOException

saveAsPNG

public void saveAsPNG(JAOutputStream jouts,
                      boolean vflippng)
               throws java.io.IOException
Saves this image in PNG format on the specified output stream, vertically flipped if vflippng is true.

Throws:
java.io.IOException