Image object

Image object

image (picture).




string, url where this image came from.
integer, pixels, width of the image. read-only property.
integer, pixels, height of the image. read-only property.


( elementWidth:integer, elementHeight:integer, [imageWidth:integer, imageHeight:integer] [, clearBy: color], elem: Element  )  or
( imageWidth:integer, imageHeight:integer [, clearBy: color], renderer: function  )

First form constructs new Image object and renders element on it as if element is given elementWidth/Height. If imageWidth/Height is provided then the function will try to scale/inscribe the element into that box.

Second form constructs new Image object and calls function renderer(gfx:Graphics) passing image bound graphics object as a parameter.

Optional clearBy defines color the bitmap will be initialized with. By default image is initilized by argb(0,0,0,0) color.


Destroys underlying native bitmap. Use this method to force the image to release its bitmap (that can be pretty big) when it is not needed.

( [compressionLevel:integer]  ) : Bytes

Saves content of the image as a byte vector that can be used e.g. for uploading on the server.

compressionLevel is a number in the range 10..100 – JPEG compression level. If it is omitted or zero then the image is saved using PNG encoding.

(  bytes : Bytes  ) : Image

Static method, constructs image from bytes. The data bytes can contain any supported image packaging format : PNG, JPEG, etc.

( )

The method returns width,height pair in one call, use it like this:
var (w,h) = img.size();

( x: integer, y: integer [, c: color] ) : color

The method returns pixel color at x,y of the image. If new color c is provided then the method sets image pixel to that color.

( mask: Image [, #luminance | #r | #g | #b | #a ] )

This method allows to set alpha channel of the image from other image. By default, if second parameter is not provided, the method uses luminance of pixel in mask image as alpha value of corresponding pixel of this image. #r, #g, #b or #a –  use mask’s red, green, blue or alpha channels as alpha values.

( src: Image , compositionOp, [dstX,dstY, [srcX,srcY,srcW, srcH ]]] ) : this image

This method allows to compose two images: this (dst) with the src Image.

compositionOp is one of composition opeatrions: #src-over, #dst-over, #src-in, #dst-in, #src-out, #dst-out, #src-atop, #dst-atop, #xor, #copy.

( renderer: function [, clearBy: color ] )

This method allows to render on existing image by calling function renderer(gfx:Graphics) passing image bound graphics object as a parameter. If clearBy parameter is provided and is a color then it is used to clear the image surface before rendering.