com.flagstone.transform
Class FSDefineImage

java.lang.Object
  extended by com.flagstone.transform.FSTransformObject
      extended by com.flagstone.transform.FSMovieObject
          extended by com.flagstone.transform.FSDefineObject
              extended by com.flagstone.transform.FSDefineImage
All Implemented Interfaces:
java.lang.Cloneable

public class FSDefineImage
extends FSDefineObject

FSDefineImage 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 images where the image data specifies the colour directly.

Attributes
type Identifies the data structure when it is encoded. Read-only.
identifier A unique identifier, in the range 1..65535, that is used to reference the image from other objects.
width Width of the image in pixels, NOT twips. 1 pixel = 20 twips.
height Height of the image in pixels, NOT twips. 1 pixel = 20 twips.
pixelSize The number of bits per pixel, either 16 or 24.
tableSize The number of entries in the colour table - which is compressed as part of the image. Each entry in the colour table contains one byte each for the red, green and blue colour channels. The colour table is only used for indexed colour images. The table is not used when the colour is specified directly in each pixel.
compressedData An array of bytes containing the zlib compressed colour table and image.

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.

History

The FSDefineImage class represents the DefineBitsLossless tag from the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 2.


Field Summary
 
Fields inherited from class com.flagstone.transform.FSDefineObject
identifier
 
Fields inherited from class com.flagstone.transform.FSMovieObject
ButtonColorTransform, ButtonSound, DefineBitsPtr, DefineButton, DefineButton2, DefineFont, DefineFont2, DefineImage, DefineImage2, DefineJPEGImage, DefineJPEGImage2, DefineJPEGImage3, DefineMorphShape, DefineMovieClip, DefineShape, DefineShape2, DefineShape3, DefineSound, DefineText, DefineText2, DefineTextField, DefineVideo, DoAction, EnableDebugger, EnableDebugger2, Export, extendLength, FontInfo, FontInfo2, FrameLabel, Free, Import, Initialize, JPEGTables, length, LimitScript, PathsArePostscript, PlaceObject, PlaceObject2, Protect, QuicktimeMovie, RemoveObject, RemoveObject2, SerialNumber, SetBackgroundColor, ShowFrame, SoundStreamBlock, SoundStreamHead, SoundStreamHead2, StartSound, TabOrder, type, VideoFrame
 
Constructor Summary
FSDefineImage(FSCoder coder)
          Construct an FSDefineImage object, initialising it with values decoded from an encoded object.
FSDefineImage(FSDefineImage obj)
          Constructs an FSDefineImage object by copying values from an existing object.
FSDefineImage(int anIdentifier, int width, int height, byte[] compressedBytes, int aPixelSize)
          Constructs an FSDefineImage object defining an image that specifies the colour directly.
FSDefineImage(int anIdentifier, int width, int height, int tableSize, byte[] compressedBytes)
          Constructs an FSDefineImage object defining a colour-mapped image.
 
Method Summary
 void appendDescription(java.lang.StringBuffer buffer, int depth)
          AppendDescription is used to present a string description of the object including all nested objects up to a specified depth.
 java.lang.Object clone()
          Creates a deep copy of the entire object.
 void decode(FSCoder coder)
           
 void encode(FSCoder coder)
           
 boolean equals(java.lang.Object anObject)
          Returns true if anObject is equal to this one.
 byte[] getCompressedData()
          Gets the compressed colour table and image.
 int getHeight()
          Gets the height of the image.
 int getPixelSize()
          Gets the number of bits used to represent each pixel.
 int getTableSize()
          Gets the number of entries in the colour table encoded the compressed image.
 int getWidth()
          Gets the width of the image.
 int length(FSCoder coder)
           
 void setCompressedData(byte[] bytes)
          Sets the compressed image data using compressed data.
 void setHeight(int aNumber)
          Sets the height of the image.
 void setPixelSize(int aNumber)
          Sets the size of the pixel in bits: 8, 16 or 32.
 void setTableSize(int aNumber)
          Sets the number of entries in the colour table in the compressed image.
 void setWidth(int aNumber)
          Sets the width of the image
 
Methods inherited from class com.flagstone.transform.FSDefineObject
getIdentifier, setIdentifier
 
Methods inherited from class com.flagstone.transform.FSMovieObject
getType
 
Methods inherited from class com.flagstone.transform.FSTransformObject
name, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FSDefineImage

public FSDefineImage(FSCoder coder)
Construct an FSDefineImage object, initialising it with values decoded from an encoded object.

Parameters:
coder - an FSCoder containing the binary data.

FSDefineImage

public FSDefineImage(int anIdentifier,
                     int width,
                     int height,
                     int tableSize,
                     byte[] compressedBytes)
Constructs an FSDefineImage object defining a colour-mapped image.

Parameters:
anIdentifier - the unique identifier for this object
width - the width of the image.
height - the height of the image.
tableSize - the number of entries in the colour table in the compressed data. Each entry is 24 bits.
compressedBytes - the zlib compressed colour table and image data.

FSDefineImage

public FSDefineImage(int anIdentifier,
                     int width,
                     int height,
                     byte[] compressedBytes,
                     int aPixelSize)
Constructs an FSDefineImage object defining an image that specifies the colour directly.

Parameters:
anIdentifier - the unique identifier for this object
width - the width of the image.
height - the height of the image.
compressedBytes - the zlib compressed image data.
aPixelSize - the size of each pixel, either 16 or 24 bits.

FSDefineImage

public FSDefineImage(FSDefineImage obj)
Constructs an FSDefineImage object by copying values from an existing object.

Parameters:
obj - an FSDefineImage object.
Method Detail

getWidth

public int getWidth()
Gets the width of the image.

Returns:
the width of the image.

getHeight

public int getHeight()
Gets the height of the image.

Returns:
the height of the image in pixels.

getPixelSize

public int getPixelSize()
Gets the number of bits used to represent each pixel. Either 8, 16 or 24 bits. The pixel size is 8-bits for colour-mapped images and 16 or 24 bits for images where the colour is specified directly.

Returns:
the number of bits per pixel: 8, 16 or 24.

getTableSize

public int getTableSize()
Gets the number of entries in the colour table encoded the compressed image. For images where the colour is specified directly in the image then the table size is zero.

Returns:
the number of entries in the colour table.

getCompressedData

public byte[] getCompressedData()
Gets the compressed colour table and image.

Returns:
an array of bytes containing the compressed colour table and image.

setWidth

public void setWidth(int aNumber)
Sets the width of the image

Parameters:
aNumber - the width of the image.

setHeight

public void setHeight(int aNumber)
Sets the height of the image.

Parameters:
aNumber - the height of the image in pixels.

setPixelSize

public void setPixelSize(int aNumber)
Sets the size of the pixel in bits: 8, 16 or 32. The pixel size is 8-bits for colour-mapped images and 16 or 24 bits for images where the colour is specified directly.

Parameters:
aNumber - the size of each pixel in bits: 8, 16 or 24.

setTableSize

public void setTableSize(int aNumber)
Sets the number of entries in the colour table in the compressed image. For images where the colour is specified directly in the image then the table size should be zero.

Parameters:
aNumber - the number of entries in the colour table in the compressed image.

setCompressedData

public void setCompressedData(byte[] bytes)
Sets the compressed image data using compressed data.

Parameters:
bytes - byte array containing zlib compressed colour table and image.

clone

public java.lang.Object clone()
Description copied from class: FSTransformObject
Creates a deep copy of the entire object.

Overrides:
clone in class FSTransformObject
Returns:
a copy of the object.

equals

public boolean equals(java.lang.Object anObject)
Description copied from class: FSMovieObject
Returns true if anObject is equal to this one. Objects are considered equal if they would generate identical binary data when they are encoded to a Flash file.

Overrides:
equals in class FSMovieObject
Returns:
true if this object would be identical to anObject when encoded.

appendDescription

public void appendDescription(java.lang.StringBuffer buffer,
                              int depth)
Description copied from class: FSTransformObject
AppendDescription is used to present a string description of the object including all nested objects up to a specified depth. This method provide a more controlled way of creating a string representation of an object since large objects such as font or shape definitions can contain dozens of nested objects. The representation of the object is appended to the StringBuffer, showing the name of the class and values of the attributes it contains. If the object contains any attributes that are objects then the object graph will be traversed up to the specified depth. If objects are nested at a level less than specified depth then the full string representation of the object is displayed. For objects at the specified depth only the name of the class is displayed. Any objects below this depth are not displayed.

Overrides:
appendDescription in class FSDefineObject
Parameters:
buffer - a StringBuffer to which the description of each object is appended.
depth - the maximum level of nesting up to which objects will be displayed.

length

public int length(FSCoder coder)
Overrides:
length in class FSDefineObject

encode

public void encode(FSCoder coder)
Overrides:
encode in class FSDefineObject

decode

public void decode(FSCoder coder)
Overrides:
decode in class FSDefineObject