Class “Image”

Object > Image

Represents an image. See also ImageValue

Type: Image extends Object
Constructor: public
Singleton: No
Namespace: tabris
Direct subclasses: None
JSX Support: No

Examples

JavaScript

import {Image} from 'tabris';

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

Constructor

new Image(imageLike)

Parameter Type Description
imageLike ImageLikeObject 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 Description
imageValue ImageValue 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 Description
value any The value to test

Returns: boolean

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 Description
value any The value to test

Returns: boolean

Properties

height

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

Type: number | 'auto'
Settable: 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

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

src

As a string this is a file system path, relative path or URL. Data URIs are also supported. 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. If a closed ImageBitmap is given the constructor will throw. A given Blob must contain an encoded image.

Type: string
| ImageBitmap
| Blob
Settable: 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

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