Packagede.popforge.imageprocessing.core
Interfacepublic interface IImage
ImplementorsImage, LayerManager

The IImage interface defines basic functions for every image.

It is important to see the difference between multi-layered and simple images. Simple images consist of one layer and are always merged because they only have one layer.

Images consiting of more than one layer can not have methods like setPixel() for instance because you can only set a pixel on a specified layer.



Public Properties
 PropertyDefined by
  bitmapData : BitmapData
[read-only] The merged version of the image.
IImage
  format : int
[read-only] The format of the image.
IImage
  height : int
[read-only] The height of the image in pixels.
IImage
  rect : Rectangle
[read-only] The rectangle that defines the size of the image.
IImage
  width : int
[read-only] The width of the image in pixels.
IImage
Public Methods
 MethodDefined by
  
getPixel(x:int, y:int):int
Returns 24-BIT pixel in 0xRRGGBB order.
IImage
  
getPixel32(x:int, y:int):int
Same as getPixel() but returns a 32-BIT integer in 0xAARRGGBB order.
IImage
  
loadBitmapData(bitmap:BitmapData, convertToGrayscale:Boolean = false):void
This function loads the information a BitmapData provides.
IImage
  
render(target:BitmapData):void
Renders the image merged on a given BitmapData object.
IImage
  
toJPEG(quality:int = 80):ByteArray
Builds and returns a JPEG file of the merged image.
IImage
  
toPNG(alpha:Boolean = true):ByteArray
Builds and returns a PNG file of the Image object.
IImage
  
toString():String
Builds and returns a string that lists the properties of the Image object.
IImage
Property detail
bitmapDataproperty
bitmapData:BitmapData  [read-only]

The merged version of the image. Never forget to free the memory you used since this propertie always returns a new BitmapData object.

Implementation
    public function get bitmapData():BitmapData

See also

formatproperty 
format:int  [read-only]

The format of the image.

Implementation
    public function get format():int

See also

heightproperty 
height:int  [read-only]

The height of the image in pixels.

Implementation
    public function get height():int
rectproperty 
rect:Rectangle  [read-only]

The rectangle that defines the size of the image.

Implementation
    public function get rect():Rectangle
widthproperty 
width:int  [read-only]

The width of the image in pixels.

Implementation
    public function get width():int
Method detail
getPixel()method
public function getPixel(x:int, y:int):int

Returns 24-BIT pixel in 0xRRGGBB order. Optional x is 0 <= x < image.width and y with 0 <= y < image.height. Remember that a binary pixel will be converted from {0;1} to {0x000000;0xffffff}

Parameters
x:int — The x coordinate of the pixel in cartesian format.
 
y:int — The y coordinate of the pixel in cartesian format.

Returns
int — 24-BIT integer with the color information of given (x|y) coordinates
getPixel32()method 
public function getPixel32(x:int, y:int):int

Same as getPixel() but returns a 32-BIT integer in 0xAARRGGBB order. If the ImageFormat does not support an alpha channel the alpha value will be set to 0xff.

Parameters
x:int — The x coordinate of the pixel in cartesian format.
 
y:int — The y coordinate of the pixel in cartesian format.

Returns
int — 32-BIT integer with the color information of given (x|y) coordinates

See also

loadBitmapData()method 
public function loadBitmapData(bitmap:BitmapData, convertToGrayscale:Boolean = false):void

This function loads the information a BitmapData provides. The BitmapData has to be in the same dimension as the Image.

Parameters
bitmap:BitmapData — BitmapData object that will be loaded.
 
convertToGrayscale:Boolean (default = false) — This indicates if BitmapData the BitmapData is already grayscale or not.

Throws
UnequalDimensionsError — Dimension of BitmapData and Image are not equal.

Example
var image: Image = new Image( bitmapData.width, bitmapData.height, ImageFormat.GRAYSCALE );
image.loadBitmapData( bitmapData, true );

render()method 
public function render(target:BitmapData):void

Renders the image merged on a given BitmapData object. Since the Image class should not be used to visualize the information an image provides we use a BitmapData object to do the job. A binary image will be converted from the {0x00;0x01} palette to {0x00;0xff}.

Parameters
target:BitmapData — BitmapData object which is used to render the Image object.

Example
var bitmap: BitmapData = new BitmapData( image.width, image.height, false, 0 );
image.render( bitmap );
addChild( new Bitmap( bitmap ) );

toJPEG()method 
public function toJPEG(quality:int = 80):ByteArray

Builds and returns a JPEG file of the merged image.

Parameters
quality:int (default = 80)

Returns
ByteArray — A ByteArray containing the JPEG file.
toPNG()method 
public function toPNG(alpha:Boolean = true):ByteArray

Builds and returns a PNG file of the Image object.

Parameters
alpha:Boolean (default = true)

Returns
ByteArray — A ByteArray containing the PNG file.
toString()method 
public function toString():String

Builds and returns a string that lists the properties of the Image object.

Returns
String — A string listing the value of each of the following properties of the Image object: width, height, format