image.eh

Images. More...

use "image.eh"

Types

type Image < Any;

Functions

def Image.get_argb(argb: [Int], ofs: Int, scanlen: Int, x: Int, y: Int, w: Int, h: Int);
def Image.graphics(): Graphics;
def Image.new(w: Int, h: Int): Image;
def image_from_argb(argb: [Int], w: Int, h: Int, alpha: Bool): Image;
def image_from_data(data: [Byte]): Image;
def image_from_file(file: String): Image;
def image_from_image(im: Image, x: Int, y: Int, w: Int, h: Int): Image;
def image_from_stream(in: IStream): Image;

Description

The Image type holds graphical image data. Images can be painted on the screen or placed in visual elements of interface. Using constructor Image.new you can create mutable image on which you can then draw. Binary image data processed by functions image_from_file, image_from_data or image_from_stream must be in one of image formats supported by the phone. Note that the only format that is guaranteed to be supported is PNG.

Type details

type Image < Any;
Graphical image data.

Function details

def Image.new(w: Int, h: Int): Image;
Creates new mutable image with given width and height. Initially every pixel of the image is white. You can draw on this image by obtaining its Graphics with Image.graphics.

def Image.graphics(): Graphics;
Creates a Graphics that renders to this image. This image must be mutable, i.e. created by Image.new constructor.

def image_from_argb(argb: [Int], w: Int, h: Int, alpha: Bool): Image;
Creates an immutable image from a sequence of ARGB values, specified as 0xAARRGGBB. The ARGB data within the argb array is arranged horizontally from left to right within each row, row by row from top to bottom. If alpha is true, the high-order byte specifies opacity; that is, 0x00RRGGBB specifies a fully transparent pixel and 0xFFRRGGBB specifies a fully opaque pixel. Intermediate alpha values specify semitransparency. If alpha is false, the alpha values are ignored and all pixels are treated as fully opaque.

def image_from_file(file: String): Image;
Reads image from file.

def image_from_stream(in: IStream): Image;
Decodes image data from input stream. Stream is left open after reading.

def image_from_data(data: [Byte]): Image;
Creates an immutable image which is decoded from the data stored in the specified byte array.

def image_from_image(im: Image, x: Int, y: Int, w: Int, h: Int): Image;
Creates an immutable image using pixel data from the specified region of a source image. This function can also be used if you want to create immutable image from mutable one.

def Image.get_argb(argb: [Int], ofs: Int, scanlen: Int, x: Int, y: Int, w: Int, h: Int);
Obtains ARGB pixel data from the specified region of this image and stores it in the array argb as integer values. The scanlen specifies the relative offset within the array between the corresponding pixels of consecutive rows. In order to prevent rows of stored pixels from overlapping, the absolute value of scanlen must be greater than or equal to width. Negative values of scanlen are allowed.