Packagede.popforge.imageprocessing.core
Classpublic class LayerManager
ImplementsIImage

The LayerManager class is a representation of one image built by multiple images on different layers.

This class is only a container of Image objects. Therefore a filter can not be applied to a LayerManager but it is possible to execute a filter on all the children of the LayerManager. The LayerManager can produced a merged output. Therefore it is an image (IImage) and can also return an encoded output (e.g. JPEG). Every LayerManager has at least one background layer. This layer has always the opacity of 100% and can not be removed.

See also

de.popforge.imageprocessing.core.Layer
de.popforge.imageprocessing.core.Image


Public Properties
 PropertyDefined by
  backgroundImage : Image
[read-only] The backgroundImage of the LayerManager.
LayerManager
  bitmapData : BitmapData
[read-only] The merged version of the image.
LayerManager
  format : int
[read-only] The format of the image.
LayerManager
  height : int
[read-only] The height of the image in pixels.
LayerManager
  layers : Array
An array of Layer objects.
LayerManager
  rect : Rectangle
[read-only] The rectangle that defines the size of the image.
LayerManager
  width : int
[read-only] The width of the image in pixels.
LayerManager
Public Methods
 MethodDefined by
  
LayerManager(width:int, height:int, format:int, backgroundImage:Image)
Creates a new LayerManager object.
LayerManager
  
addLayer(layer:Layer):void
Adds a layer to the top.
LayerManager
  
Executes a filter on all layers.
LayerManager
  
fromBitmapData(bitmap:BitmapData, format:int, convertToGrayscale:Boolean = false):LayerManager
[static] This function creates a new LayaerManager object from a given BitmapData object.
LayerManager
  
[static] Creates a new LayerManager object using the given image as the background layer.
LayerManager
  
getPixel(x:int, y:int):int
Returns 24-BIT pixel in 0xRRGGBB order.
LayerManager
  
getPixel32(x:int, y:int):int
Same as getPixel() but returns a 32-BIT integer in 0xAARRGGBB order.
LayerManager
  
loadBitmapData(bitmap:BitmapData, convertToGrayscale:Boolean = false):void
This function loads the information a BitmapData provides.
LayerManager
  
merge():void
Merges all layers to the background layer.
LayerManager
  
render(target:BitmapData):void
Renders the image merged on a given BitmapData object.
LayerManager
  
toJPEG(quality:int = 80):ByteArray
Builds and returns a JPEG file of the merged image.
LayerManager
  
toPNG(alpha:Boolean = true):ByteArray
Builds and returns a PNG file of the Image object.
LayerManager
  
toString():String
Builds and returns a string that lists the properties of the Image object.
LayerManager
Property detail
backgroundImageproperty
backgroundImage:Image  [read-only]

The backgroundImage of the LayerManager.

Implementation
    public function get backgroundImage():Image
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
formatproperty 
format:int  [read-only]

The format of the image.

Implementation
    public function get format():int
heightproperty 
height:int  [read-only]

The height of the image in pixels.

Implementation
    public function get height():int
layersproperty 
public var layers:Array

An array of Layer objects.

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
Constructor detail
LayerManager()constructor
public function LayerManager(width:int, height:int, format:int, backgroundImage:Image)

Creates a new LayerManager object.

Parameters
width:int — Width of image in pixel.
 
height:int — Height of image in pixel.
 
format:int — May be any kind of de.popforge.imageprocessing.core.ImageFormat
 
backgroundImage:Image — The Image object used for the background layer.
Method detail
addLayer()method
public function addLayer(layer:Layer):void

Adds a layer to the top.

Parameters
layer:Layer — The layer that should be added.
applyFilterToAll()method 
public function applyFilterToAll(filter:IFilter):void

Executes a filter on all layers.

Parameters
filter:IFilter — Any filter that should be executed.
fromBitmapData()method 
public static function fromBitmapData(bitmap:BitmapData, format:int, convertToGrayscale:Boolean = false):LayerManager

This function creates a new LayaerManager object from a given BitmapData object. The BitmapData is taken and a new image will be created with respect to the size of the BitmapData object.

Parameters
bitmap:BitmapData — BitmapData object which will be used as the background layer for the new LayerManager object.
 
format:int — The image format which may be any kind of ImageFormat.
 
convertToGrayscale:Boolean (default = false) — If your BitmapData source is not already a grayscale image you can convert it by setting convertToGrayscale to true..

Returns
LayerManager — A new LayerManager object with information from given BitmapData.

Example
LayerManager.fromBitmapData( bitmap, ImageFormat.RGB, false );

fromImage()method 
public static function fromImage(image:Image):LayerManager

Creates a new LayerManager object using the given image as the background layer.

Parameters
image:Image — The background layer of the new LayerManager object.

Returns
LayerManager — A LayerManager object based on the given Image object.
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
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.
merge()method 
public function merge():void

Merges all layers to the background layer.

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.
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