com.flagstone.transform
Class FSDefineImage2

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.FSDefineImage2
All Implemented Interfaces:
java.lang.Cloneable

public class FSDefineImage2
extends FSDefineObject

FSDefineImage2 is used to define a transparent 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. It extends FSDefineImage by including alpha channel information for the colour table and pixels in the image.

For colour-mapped images the colour table contains up to 256, 32-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 32 bit colour values.

Attributes
type Identifies the data structure when it is encoded. The type attribute is read-only and may be used when iterating through the objects in an FSMovie object to identify the object class without using run-time type checking.
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 8 or 32. 8-bit pixels are used for indexed images where the colour table contains the colours for each pixel. 32-bit pixels are used to specify the colour and transparency directly.
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.

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.

History

The FSDefineImage2 class represents the DefineBitsLossless2 tag from the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 3.


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
FSDefineImage2(FSCoder coder)
          Construct an FSCall object, initialising it with values decoded from an encoded object.
FSDefineImage2(FSDefineImage2 obj)
          Constructs an FSDefineImage2 object by copying values from an existing object.
FSDefineImage2(int anIdentifier, int width, int height, byte[] compressedBytes)
          Constructs an FSDefineImage object defining an image that specifies the colour directly.
FSDefineImage2(int anIdentifier, int width, int height, int tableSize, byte[] compressedBytes)
          Constructs an FSDefineImage2 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 for colour-mapped images, 32 for direct images.
 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

FSDefineImage2

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

Parameters:
coder - an FSCoder containing the binary data.

FSDefineImage2

public FSDefineImage2(int anIdentifier,
                      int width,
                      int height,
                      int tableSize,
                      byte[] compressedBytes)
Constructs an FSDefineImage2 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 32 bits.
compressedBytes - the zlib compressed colour table and image data.

FSDefineImage2

public FSDefineImage2(int anIdentifier,
                      int width,
                      int height,
                      byte[] compressedBytes)
Constructs an FSDefineImage object defining an image that specifies the colour directly. Each pixel in the image is 32 bits - 8 bits for the red, green, blue and alpha colour channels.

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.

FSDefineImage2

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

Parameters:
obj - an FSDefineImage2 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 or 32 bits. The pixel size is 8-bits for colour-mapped images and 32 bits for images where the colour is specified directly.

Returns:
the number of bits per pixel: 8 or 32.

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 for colour-mapped images, 32 for direct images.

Parameters:
aNumber - the size of each pixel in bits: 8 or 32.

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