Interface IImage<TNative, TProps>

Since

0.1

Image is used to store the image data read from the filesystem. It can be set to UI objects' properties (e.g. UI.ImageView.image).

Example

import Image from '@smartface/native/ui/image';
import ImageView from '@smartface/native/ui/imageview';

var myImage = Image.createFromFile("images://smartface.png")
var myImageView = new ImageView({
image: myImage,
width: 200, height: 200
});

myPage.layout.addChild(myImageView);

Type Parameters

Hierarchy

  • INativeMobileComponent<TNative, TProps>
    • IImage

Implemented by

Properties

nativeObject: TNative
ios: TProps["ios"]
android: TProps["android"]
height: number

Gets the height of image in pixels.

Android

Ios

Property

Since

0.1

width: number

Gets the width of image in pixels.

Android

Ios

Property

Since

0.1

autoMirrored: boolean

Gets/Sets the autoMirrored of image. This property sets direction of Image automatically related to system or application direction.

Ios

Android

Property

Since

3.1.3

Methods

  • Returns a Blob instance.

    Android

    Ios

    Method

    toBlob

    Returns

    Blob

    Since

    0.1

    Returns null | IBlob<any, MobileOSProps<{}, IBlobAndroidProps>>

  • Creates a new image from existing image with specified width and height. onSuccess and onFailure are optional parameters.

    Example

    import Image from '@smartface/native/ui/image';
    import ImageView from '@smartface/native/ui/imageview';
    var myImage = Image.createFromFile("images://smartface.png")
    var myImageView = new ImageView();
    myImageView.image = myImage.resize(myImage.width/2, myImage.height/2); // resize example without callback


    import Image from '@smartface/native/ui/image';
    import ImageView from '@smartface/native/ui/imageview';
    var myImage = Image.createFromFile("images://smartface.png")
    var myImageView = new ImageView();
    myImage.resize(myImage.width/2, myImage.height/2, onSuccess);

    function onSuccess(e) {
    myImageView.image = e.image
    }

    Method

    resize

    Returns

    UI.Image

    Android

    Ios

    Since

    0.1

    Parameters

    Returns null | void | IImage<any, MobileOSProps<ImageIOSProps, ImageAndroidProps>>

  • Returns a cropped image from existing image with specified rectangle. onSuccess and onFailure are optional parameters.

    Method

    crop

    Returns

    UI.Image

    Android

    Ios

    Since

    0.1

    Parameters

    • x: number

      The x pixels of the rectangle top-left corner.

    • y: number

      The y pixels of the rectangle top-left corner.

    • width: number

      Width pixels of the new bitmap.

    • height: number

      Height pixels of the new bitmap.

    • Optional onSuccess: ((e: { image: IImage<any, MobileOSProps<ImageIOSProps, ImageAndroidProps>> }) => void)

      Callback for success situation.

    • Optional onFailure: ((e?: { message: string }) => void)

      Callback for failure situation.

        • (e?: { message: string }): void
        • Parameters

          • Optional e: { message: string }
            • message: string

          Returns void

    Returns null | void | IImage<any, MobileOSProps<ImageIOSProps, ImageAndroidProps>>

  • Returns a compressed blob from existing image with given quality. onSuccess and onFailure are optional parameters.

    Example

    import Image from '@smartface/native/ui/image';
    var myImage = Image.createFromFile("images://smartface.png")
    var myBlob = myImage.compress(Image.Format.JPEG, 50);
    var myCompressedImage = Image.createFromBlob(myBlob);

    Method

    compress

    Returns

    Blob

    Android

    Ios

    Since

    0.1

    Parameters

    • format: Format

      Image format.

    • quality: number

      Image quality is between 0 and 100.

    • Optional onSuccess: ((e: { blob: IBlob<any, MobileOSProps<{}, IBlobAndroidProps>> }) => void)

      Callback for success situation.

    • Optional onFailure: ((e?: { message: string }) => void)

      Callback for failure situation.

        • (e?: { message: string }): void
        • Parameters

          • Optional e: { message: string }
            • message: string

          Returns void

    Returns null | void | IBlob<any, MobileOSProps<{}, IBlobAndroidProps>>

Generated using TypeDoc