Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ImageSource

Encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images.

Hierarchy

  • ImageSource

Index

Constructors

constructor

  • Creates a new ImageSource instance and sets the provided native source object (typically a Bitmap). The native source object will update either the android or ios properties, depending on the target os.

    Parameters

    • Optional nativeSource: any

      The native image object. Will be either a Bitmap for Android or a UIImage for iOS.

    Returns ImageSource

Properties

android

android: any

The Android-specific image instance. Will be undefined when running on iOS.

height

height: number

Gets the height of this instance. This is a read-only property.

ios

ios: any

The iOS-specific UIImage instance. Will be undefined when running on Android.

rotationAngle

rotationAngle: number

Gets or sets the rotation angle that should be applied to the image. (Used in android)

width

width: number

Gets the width of this instance. This is a read-only property.

Methods

fromAsset

  • deprecated

    Use ImageSource.fromAsset() instead. Loads this instance from the specified asset asynchronously.

    Parameters

    • asset: ImageAsset

      The ImageAsset instance used to create ImageSource.

    Returns Promise<ImageSource>

fromBase64

  • fromBase64(source: string): Promise<boolean>
  • deprecated

    Use ImageSource.fromBase64() instead. Loads this instance from the specified base64 encoded string asynchronously.

    Parameters

    • source: string

      The Base64 string to load the image from.

    Returns Promise<boolean>

fromData

  • fromData(data: any): Promise<boolean>
  • deprecated

    Use ImageSource.fromData() instead. Loads this instance from the specified native image data asynchronously.

    Parameters

    • data: any

      The native data (byte array) to load the image from. This will be either Stream for Android or NSData for iOS.

    Returns Promise<boolean>

fromFile

  • fromFile(path: string): Promise<boolean>
  • deprecated

    Use ImageSource.fromFile() instead. Loads this instance from the specified file asynchronously.

    Parameters

    • path: string

      The location of the file on the file system.

    Returns Promise<boolean>

fromResource

  • fromResource(name: string): Promise<boolean>
  • deprecated

    Use ImageSource.fromResource() instead. Loads this instance from the specified resource name asynchronously.

    Parameters

    • name: string

      The name of the resource (without its extension).

    Returns Promise<boolean>

loadFromBase64

  • loadFromBase64(source: string): boolean
  • deprecated

    Use ImageSource.fromBase64Sync() instead. Loads this instance from the specified base64 encoded string.

    Parameters

    • source: string

      The Base64 string to load the image from.

    Returns boolean

loadFromData

  • loadFromData(data: any): boolean
  • deprecated

    Use ImageSource.fromDataSync() instead. Loads this instance from the specified native image data.

    Parameters

    • data: any

      The native data (byte array) to load the image from. This will be either Stream for Android or NSData for iOS.

    Returns boolean

loadFromFile

  • loadFromFile(path: string): boolean
  • deprecated

    Use ImageSource.fromFileSync() instead. Loads this instance from the specified file.

    Parameters

    • path: string

      The location of the file on the file system.

    Returns boolean

loadFromFontIconCode

  • loadFromFontIconCode(source: string, font: Font, color: Color): boolean
  • deprecated

    Use ImageSource.fromFontIconCode() instead. Loads this instance from the specified font icon code.

    Parameters

    • source: string

      The hex font icon code string

    • font: Font

      The font for the corresponding font icon code

    • color: Color

      The color of the generated icon image

    Returns boolean

loadFromResource

  • loadFromResource(name: string): boolean
  • deprecated

    Use ImageSource.fromResourceSync() instead. Loads this instance from the specified resource name.

    Parameters

    • name: string

      The name of the resource (without its extension).

    Returns boolean

resize

  • Returns a new ImageSource that is a resized version of this image with the same aspect ratio, but the max dimension set to the provided maxSize.

    Parameters

    • maxSize: number

      The maximum pixel dimension of the resulting image.

    • Optional options: any

      Optional parameter, Only used for android, options.filter is a boolean which determines whether or not bilinear filtering should be used when scaling the bitmap. If this is true then bilinear filtering will be used when scaling which has better image quality at the cost of worse performance. If this is false then nearest-neighbor scaling is used instead which will have worse image quality but is faster. Recommended default is to set filter to 'true' as the cost of bilinear filtering is typically minimal and the improved image quality is significant.

    Returns ImageSource

saveToFile

  • saveToFile(path: string, format: "png" | "jpeg" | "jpg", quality?: number): boolean
  • Saves this instance to the specified file, using the provided image format and quality.

    Parameters

    • path: string

      The path of the file on the file system to save to.

    • format: "png" | "jpeg" | "jpg"

      The format (encoding) of the image.

    • Optional quality: number

      Optional parameter, specifying the quality of the encoding. Defaults to the maximum available quality. Quality varies on a scale of 0 to 100.

    Returns boolean

setNativeSource

  • setNativeSource(nativeSource: any): void
  • Sets the provided native source object (typically a Bitmap or a UIImage). This will update either the android or ios properties, depending on the target os.

    Parameters

    • nativeSource: any

      The native image object. Will be either a Bitmap for Android or a UIImage for iOS.

    Returns void

toBase64String

  • toBase64String(format: "png" | "jpeg" | "jpg", quality?: number): string
  • Converts the image to base64 encoded string, using the provided image format and quality.

    Parameters

    • format: "png" | "jpeg" | "jpg"

      The format (encoding) of the image.

    • Optional quality: number

      Optional parameter, specifying the quality of the encoding. Defaults to the maximum available quality. Quality varies on a scale of 0 to 100.

    Returns string

Static fromAsset

Static fromBase64

  • Loads this instance from the specified base64 encoded string asynchronously.

    Parameters

    • source: string

      The Base64 string to load the image from.

    Returns Promise<ImageSource>

Static fromBase64Sync

  • Loads this instance from the specified base64 encoded string.

    Parameters

    • source: string

      The Base64 string to load the image from.

    Returns ImageSource

Static fromData

  • Loads this instance from the specified native image data asynchronously.

    Parameters

    • data: any

      The native data (byte array) to load the image from. This will be either Stream for Android or NSData for iOS.

    Returns Promise<ImageSource>

Static fromDataSync

  • Loads this instance from the specified native image data.

    Parameters

    • data: any

      The native data (byte array) to load the image from. This will be either Stream for Android or NSData for iOS.

    Returns ImageSource

Static fromFile

  • Loads this instance from the specified file asynchronously.

    Parameters

    • path: string

      The location of the file on the file system.

    Returns Promise<ImageSource>

Static fromFileOrResourceSync

  • Creates a new ImageSource instance and loads it from the specified local file or resource (if specified with the "res://" prefix).

    Parameters

    • path: string

      The location of the file on the file system.

    Returns ImageSource

Static fromFileSync

Static fromFontIconCodeSync

  • Creates a new ImageSource instance and loads it from the specified font icon code.

    Parameters

    • source: string

      The hex font icon code string

    • font: Font

      The font for the corresponding font icon code

    • color: Color

      The color of the generated icon image

    Returns ImageSource

Static fromResource

  • Loads this instance from the specified resource name asynchronously.

    Parameters

    • name: string

      The name of the resource (without its extension).

    Returns Promise<ImageSource>

Static fromResourceSync

  • Loads this instance from the specified resource name.

    Parameters

    • name: string

      The name of the resource (without its extension).

    Returns ImageSource

Static fromUrl

  • Downloads the image from the provided Url and creates a new ImageSource instance from it.

    Parameters

    • url: string

      The link to the remote image object. This operation will download and decode the image.

    Returns Promise<ImageSource>

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method