|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.flagstone.transform.image.DefineImage
public final class DefineImage
DefineImage is used to define an image compressed using the lossless zlib compression algorithm.
The class supports colour-mapped images where the image data contains an index into a colour table or direct-mapped images where the colour is specified directly.
For colour-mapped images the colour table contains up to 256, 24-bit colours. The image contains one byte for each pixel which is an index into the table to specify the colour for that pixel. The colour table and the image data are compressed as a single block, with the colour table placed before the image.
For images where the colour is specified directly, the image data contains either 16 or 24 bit colour values. For 16-bit colour values the most significant bit is zero followed by three, 5-bit fields for the red, green and blue channels:
+-+--------+--------+--------+ |0| Red | Green | Blue | +-+--------+--------+--------+ 15 0
Four bytes are used to represent 24-bit colours. The first byte is always set to zero and the following bytes contain the colour values for the red, green and blue colour channels.
The number of bytes in each row of an image must be aligned to a 32-bit word boundary. For example if an image if an icon is 25 pixels wide, then for an 8-bit colour mapped image an additional three bytes (0x00) must be used to pad each row; for a 16-bit direct mapped colour image an additional two bytes must be used as padding.
The image data is stored in zlib compressed form within the object. For colour-mapped images the compressed data contains the colour table followed by the image data. The colour table is omitted for direct-mapped images.
DefineImage2| Constructor Summary | |
|---|---|
DefineImage(DefineImage object)
Creates and initialises a DefineImage object using the values copied from another DefineImage object. |
|
DefineImage(int uid,
int imgWidth,
int imgHeight,
byte[] data,
int size)
Creates a DefineImage object defining an true-colour image. |
|
DefineImage(int uid,
int imgWidth,
int imgHeight,
int size,
byte[] data)
Creates a DefineImage object defining a colour-mapped image. |
|
DefineImage(SWFDecoder coder)
Creates and initialises a DefineImage object using values encoded in the Flash binary format. |
|
| Method Summary | |
|---|---|
DefineImage |
copy()
Creates a complete copy of this object. |
void |
encode(SWFEncoder coder,
Context context)
Encode an object to the Flash binary format. |
int |
getHeight()
Get the height of the image in pixels (not twips). |
int |
getIdentifier()
Get the unique identifier assigned to this object. |
byte[] |
getImage()
Get a copy of the compressed colour table and image. |
int |
getPixelSize()
Returns the number of bits used to represent each pixel. |
int |
getTableSize()
Get the number of entries in the colour table encoded the compressed image. |
int |
getWidth()
Get the width of the image in pixels (not twips). |
int |
prepareToEncode(Context context)
Prepare an object for encoding, returning the expected size of an object when it is encoded. |
void |
setHeight(int aNumber)
Sets the height of the image in pixels. |
void |
setIdentifier(int uid)
Sets the unique identifier for an object within a given Movie. |
void |
setImage(byte[] bytes)
Sets the data containing the compressed image and colour table. |
void |
setPixelSize(int size)
Sets the size of the pixel in bits: 8, 16 or 32. |
void |
setTableSize(int size)
Sets the number of entries in the colour table in the compressed image. |
void |
setWidth(int aNumber)
Sets the width of the image in pixels. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DefineImage(SWFDecoder coder)
throws IOException
coder - an SWFDecoder object that contains the encoded Flash data.
IOException - if an error occurs while decoding the data.
public DefineImage(int uid,
int imgWidth,
int imgHeight,
int size,
byte[] data)
uid - the unique identifier for this object. Must be in the range
1..65535.imgWidth - the width of the image. Must be in the range 0..65535.imgHeight - the height of the image. Must be in the range 0..65535.size - the number of entries in the colour table in the compressed
data. Each entry is 24 bits. Must be in the range 1..256.data - the zlib compressed colour table and image data.
public DefineImage(int uid,
int imgWidth,
int imgHeight,
byte[] data,
int size)
uid - the unique identifier for this object. Must be in the range
1..65535.imgWidth - the width of the image. Must be in the range 0..65535.imgHeight - the height of the image. Must be in the range 0..65535.data - the zlib compressed image data.size - the size of each pixel, either 16 or 24 bits.public DefineImage(DefineImage object)
object - a DefineImage object from which the values will be
copied.| Method Detail |
|---|
public int getIdentifier()
getIdentifier in interface DefineTagpublic void setIdentifier(int uid)
setIdentifier in interface DefineTaguid - a unique identifier for the object. Must be in the range
1..65535.public int getWidth()
getWidth in interface ImageTagpublic int getHeight()
getHeight in interface ImageTagpublic int getPixelSize()
public int getTableSize()
public byte[] getImage()
public void setWidth(int aNumber)
aNumber - the width of the image. Must be in the range 0..65535.public void setHeight(int aNumber)
aNumber - the height of the image in pixels. Must be in the range
0..65535.public void setPixelSize(int size)
size - the size of each pixel in bits. Must be either 8, 16 or 24.public void setTableSize(int size)
size - the number of entries in the colour table in the compressed
image, in the range 1..256.public void setImage(byte[] bytes)
bytes - byte array containing zlib compressed colour table and image.
Must not be null.public DefineImage copy()
copy in interface Copyable<MovieTag>public String toString()
toString in class Objectpublic int prepareToEncode(Context context)
prepareToEncode in interface SWFEncodeablecontext - an Context that allows information to be passed between
objects to control how they are initialised for encoding.
public void encode(SWFEncoder coder,
Context context)
throws IOException
encode in interface SWFEncodeablecoder - an SWFEncoder object.context - an Context that allows information to be passed between
objects to control how they are initialised for encoding.
IOException - if an error occurs while encoding the object.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||