Packagexp.graphics
Classpublic class GIFDecoder

Decodes a GIF file into one or more frames.
 



Public Properties
 PropertyDefined by
  STATUS_FORMAT_ERROR : int = 1
[static] File read status: Error decoding file (may be partially decoded)
GIFDecoder
  STATUS_OK : int = 0
[static] File read status: No errors.
GIFDecoder
  STATUS_OPEN_ERROR : int = 2
[static] File read status: Unable to open source.
GIFDecoder
Protected Properties
 PropertyDefined by
  act : Array
GIFDecoder
  bgColor : int
GIFDecoder
  bgIndex : int
GIFDecoder
  block : ByteArray
GIFDecoder
  blockSize : int = 0
GIFDecoder
  data : ByteArray
GIFDecoder
  delay : int = 0
GIFDecoder
  dispose : int = 0
GIFDecoder
  frameCount : int
GIFDecoder
  frames : Array
GIFDecoder
  gct : Array
GIFDecoder
  gctFlag : Boolean
GIFDecoder
  gctSize : int
GIFDecoder
  height : int
GIFDecoder
  ih : int
GIFDecoder
  image : BitmapData
GIFDecoder
  interlace : Boolean
GIFDecoder
  iw : int
GIFDecoder
  ix : int
GIFDecoder
  iy : int
GIFDecoder
  lastBgColor : int
GIFDecoder
  lastDispose : int = 0
GIFDecoder
  lastImage : BitmapData
GIFDecoder
  lastRect : Rectangle
GIFDecoder
  lct : Array
GIFDecoder
  lctFlag : Boolean
GIFDecoder
  lctSize : int
GIFDecoder
  loopCount : int = 1
GIFDecoder
  MaxStackSize : int = 4096
[static]
GIFDecoder
  pixelAspect : int
GIFDecoder
  pixels : ByteArray
GIFDecoder
  pixelStack : ByteArray
GIFDecoder
  prefix : Array
GIFDecoder
  status : int
GIFDecoder
  suffix : ByteArray
GIFDecoder
  transIndex : int
GIFDecoder
  transparency : Boolean = false
GIFDecoder
  width : int
GIFDecoder
Public Methods
 MethodDefined by
  
getDelay(n:int):int
Gets display duration for specified frame.
GIFDecoder
  
getFrame(n:int):BitmapData
Gets the image contents of frame n.
GIFDecoder
  
Gets the number of frames read from file.
GIFDecoder
  
Gets image height.
GIFDecoder
  
getFrames():Array
Return the frames array
GIFDecoder
  
Gets image width.
GIFDecoder
  
getImage():BitmapData
Gets the first (or only) image read.
GIFDecoder
  
Gets the "Netscape" iteration count, if any.
GIFDecoder
  
read(input:ByteArray):int
Reads GIF image from stream
GIFDecoder
  
release():void
Release all resources
GIFDecoder
Protected Methods
 MethodDefined by
  
Decodes LZW image data into pixel array.
GIFDecoder
  
err():Boolean
Returns true if an error was encountered during reading/decoding
GIFDecoder
  
init():void
Initializes or re-initializes reader
GIFDecoder
  
readBlock():int
Reads next variable length block from input.
GIFDecoder
  
readByte():int
Reads a single byte from the input stream.
GIFDecoder
  
readColorTable(ncolors:int):Array
Reads color table as 256 RGB integer values
GIFDecoder
  
readContents():void
Main file parser.
GIFDecoder
  
Reads Graphics Control Extension values
GIFDecoder
  
readHeader():void
Reads GIF file header information.
GIFDecoder
  
readImage():void
Reads next frame image
GIFDecoder
  
readLSD():void
Reads Logical Screen Descriptor
GIFDecoder
  
Reads Netscape extenstion to obtain iteration count
GIFDecoder
  
readShort():int
Reads next 16-bit value, LSB first
GIFDecoder
  
resetFrame():void
Resets frame state for reading next image.
GIFDecoder
  
setPixels():void
Creates new frame image from current data (and previous frames as specified by their disposition codes).
GIFDecoder
  
skip():void
Skips variable length blocks up to and including next zero length block.
GIFDecoder
Property detail
actproperty
protected var act:Array
bgColorproperty 
protected var bgColor:int
bgIndexproperty 
protected var bgIndex:int
blockproperty 
protected var block:ByteArray
blockSizeproperty 
protected var blockSize:int = 0
dataproperty 
protected var data:ByteArray
delayproperty 
protected var delay:int = 0
disposeproperty 
protected var dispose:int = 0
frameCountproperty 
protected var frameCount:int
framesproperty 
protected var frames:Array
gctproperty 
protected var gct:Array
gctFlagproperty 
protected var gctFlag:Boolean
gctSizeproperty 
protected var gctSize:int
heightproperty 
protected var height:int
ihproperty 
protected var ih:int
imageproperty 
protected var image:BitmapData
interlaceproperty 
protected var interlace:Boolean
iwproperty 
protected var iw:int
ixproperty 
protected var ix:int
iyproperty 
protected var iy:int
lastBgColorproperty 
protected var lastBgColor:int
lastDisposeproperty 
protected var lastDispose:int = 0
lastImageproperty 
protected var lastImage:BitmapData
lastRectproperty 
protected var lastRect:Rectangle
lctproperty 
protected var lct:Array
lctFlagproperty 
protected var lctFlag:Boolean
lctSizeproperty 
protected var lctSize:int
loopCountproperty 
protected var loopCount:int = 1
MaxStackSizeproperty 
protected static var MaxStackSize:int = 4096
pixelAspectproperty 
protected var pixelAspect:int
pixelsproperty 
protected var pixels:ByteArray
pixelStackproperty 
protected var pixelStack:ByteArray
prefixproperty 
protected var prefix:Array
statusproperty 
protected var status:int
STATUS_FORMAT_ERRORproperty 
public static var STATUS_FORMAT_ERROR:int = 1

File read status: Error decoding file (may be partially decoded)

STATUS_OKproperty 
public static var STATUS_OK:int = 0

File read status: No errors.

STATUS_OPEN_ERRORproperty 
public static var STATUS_OPEN_ERROR:int = 2

File read status: Unable to open source.

suffixproperty 
protected var suffix:ByteArray
transIndexproperty 
protected var transIndex:int
transparencyproperty 
protected var transparency:Boolean = false
widthproperty 
protected var width:int
Method detail
decodeImageData()method
protected function decodeImageData():void

Decodes LZW image data into pixel array. Adapted from John Cristy's ImageMagick.

err()method 
protected function err():Boolean

Returns true if an error was encountered during reading/decoding

Returns
Boolean
getDelay()method 
public function getDelay(n:int):int

Gets display duration for specified frame.

Parameters
n:int — int index of frame

Returns
int — delay in milliseconds
getFrame()method 
public function getFrame(n:int):BitmapData

Gets the image contents of frame n.

Parameters
n:int

Returns
BitmapData — BufferedImage representation of frame, or null if n is invalid.
getFrameCount()method 
public function getFrameCount():int

Gets the number of frames read from file.

Returns
int — frame count
getFrameHeight()method 
public function getFrameHeight():int

Gets image height.

Returns
int — GIF image height
getFrames()method 
public function getFrames():Array

Return the frames array

Returns
Array
getFrameWidth()method 
public function getFrameWidth():int

Gets image width.

Returns
int — GIF image width
getImage()method 
public function getImage():BitmapData

Gets the first (or only) image read.

Returns
BitmapData — BufferedImage containing first frame, or null if none.
getLoopCount()method 
public function getLoopCount():int

Gets the "Netscape" iteration count, if any. A count of 0 means repeat indefinitiely.

Returns
int — iteration count if one was specified, else 1.
init()method 
protected function init():void

Initializes or re-initializes reader

read()method 
public function read(input:ByteArray):int

Reads GIF image from stream

Parameters
input:ByteArray — containing GIF file.

Returns
int — read status code (0 = no errors)
readBlock()method 
protected function readBlock():int

Reads next variable length block from input.

Returns
int — number of bytes stored in "buffer"
readByte()method 
protected function readByte():int

Reads a single byte from the input stream. RJE:(was read() but AS doesnt support overloading)

Returns
int
readColorTable()method 
protected function readColorTable(ncolors:int):Array

Reads color table as 256 RGB integer values

Parameters
ncolors:int — int number of colors to read

Returns
Array — int array containing 256 colors (packed ARGB with full alpha)
readContents()method 
protected function readContents():void

Main file parser. Reads GIF content blocks.

readGraphicControlExt()method 
protected function readGraphicControlExt():void

Reads Graphics Control Extension values

readHeader()method 
protected function readHeader():void

Reads GIF file header information.

readImage()method 
protected function readImage():void

Reads next frame image

readLSD()method 
protected function readLSD():void

Reads Logical Screen Descriptor

readNetscapeExt()method 
protected function readNetscapeExt():void

Reads Netscape extenstion to obtain iteration count

readShort()method 
protected function readShort():int

Reads next 16-bit value, LSB first

Returns
int
release()method 
public function release():void

Release all resources

resetFrame()method 
protected function resetFrame():void

Resets frame state for reading next image.

setPixels()method 
protected function setPixels():void

Creates new frame image from current data (and previous frames as specified by their disposition codes).

skip()method 
protected function skip():void

Skips variable length blocks up to and including next zero length block.