jezuch.utils.starmapper.encoders
Class RawImage

java.lang.Object
  |
  +--jezuch.utils.starmapper.encoders.RawImage

public class RawImage
extends java.lang.Object

Simple struct-like class holding Starmapper image data. RawImage has four properties: width, height, color model and raw pixel data. Color model as for now is always IndexColorModel; raw data is a byte array holding pixels as indexes in the indexed color model. NOTE: this might change in future (e.g. shaded territories).


Constructor Summary
RawImage(byte[] data, java.awt.image.IndexColorModel cm, int w, int h)
          Constructs RawImage from specified raw pixel data, IndexColorModel and size.
RawImage(java.awt.image.IndexColorModel cm, int w, int h)
          Constructs new empty RawImage with specified IndexColorModel and size.
 
Method Summary
 java.awt.image.IndexColorModel getColorModel()
           
 byte[] getData()
          Returns byte array containing raw pixel data in the indexed color model.
 int getHeight()
           
 java.awt.image.ImageProducer getProducer()
          Constructs an ImageProducer which can produce pixels for this image - this is a link to the Java's Producer-Consumer interface.
 int getWidth()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RawImage

public RawImage(byte[] data,
                java.awt.image.IndexColorModel cm,
                int w,
                int h)
Constructs RawImage from specified raw pixel data, IndexColorModel and size.

Parameters:
data - raw pixel data in 8-bit indexed color model
cm - IndexColorModel used by raw pixel data
w - width of the image, must be positive (>0)
h - height of the image, must be positive (>0)
Throws:
java.lang.IllegalArgumentException - thrown if either data or cm is null, either w or h is zero or negative or image size (w*h) doesn't match raw pixel count (data.length)

RawImage

public RawImage(java.awt.image.IndexColorModel cm,
                int w,
                int h)
Constructs new empty RawImage with specified IndexColorModel and size.

Parameters:
cm - IndexColorModel used by raw pixel data (all inited to 0)
w - width of the image, must be positive (>0)
h - height of the image, must be positive (>0)
Throws:
java.lang.IllegalArgumentException - thrown if cm is null or either w or h is zero or negative
Method Detail

getColorModel

public java.awt.image.IndexColorModel getColorModel()
Returns:
color model of this image, always IndexColorModel

getData

public byte[] getData()
Returns byte array containing raw pixel data in the indexed color model. This is not a clone of internal pixel data.

Returns:
raw pixel data of the image

getHeight

public int getHeight()
Returns:
height of the image.

getProducer

public java.awt.image.ImageProducer getProducer()
Constructs an ImageProducer which can produce pixels for this image - this is a link to the Java's Producer-Consumer interface. This producer is a MemoryImageSource reading pixels from byte array and IndexedColorModel.

Returns:
this image's ImageProducer

getWidth

public int getWidth()
Returns:
width of the image.