Class “Image”

Object > Image

Represents an image. See also ImageValue

Constructor public
Singleton No
Namespace tabris
Direct subclasses None
JSX support No

Example

import {Image} from 'tabris';

const image = Image.from({src: 'image@2x.png'});
console.log(image.scale); // "2"

Constructor

new Image(imageLike)

Parameter Type Optional Description
imageLike ImageLikeObject No An image configuration. See ImageLikeObject

Static Methods

from(imageValue)

Creates a new instance of Image using any valid Image expression. For any other value, including null, the method throws.

Parameter Type Optional Description
imageValue ImageValue No The value to create an Image instance from. See ImageValue

Returns Image

isImageValue(value)

Returns true if value is an ImageValue. This includes null. Use this to check if a value will be accepted by an image property. This is also a valid TypeScript type guard function.

Parameter Type Optional Description
value any No The value to test

Returns value is ImageValue

isValidImageValue(value)

Returns true if value is a valid ImageValue. This excludes null. Use this to check if a value will be accepted by Image.from. This is also a valid TypeScript type guard function.

Parameter Type Optional Description
value any No The value to test

Returns value is ImageValue

Properties

height

Image height in dip. Extracted from the image file when ‘auto’.

Type number | 'auto'
Settable No
Change events No

This property can only be set via constructor. Once set, it cannot change anymore.

scale

Image scale factor - the image will be scaled down by this factor. See ImageLikeObject for details

Type number | 'auto'
Settable No
Change events No

This property can only be set via constructor. Once set, it cannot change anymore.

src

File system path, relative path or URL. Android and iOS also support data URI. Relative paths are resolved relative to ‘package.json’. On Android the name of a bundled drawable resource can be provided with the url scheme android-drawable, e.g. android-drawable://ic_info_black.

Type string
Settable No
Change events No

This property can only be set via constructor. Once set, it cannot change anymore.

width

Image width in dip. Extracted from the image file when ‘auto’.

Type number | 'auto'
Settable No
Change events No

This property can only be set via constructor. Once set, it cannot change anymore.