Note: You are on the beta version of our docs. This is a work in progress and may contain broken links and pages.
Classes
ImageSource
ImageSource
Encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images.
Summary
Constructors
Properties
Methods
- fromAsset
- fromAsset
- fromBase64
- fromBase64
- fromBase64Sync
- fromData
- fromData
- fromDataSync
- fromFile
- fromFile
- fromFileOrResourceSync
- fromFileSync
- fromFontIconCodeSync
- fromResource
- fromResource
- fromResourceSync
- fromUrl
- loadFromBase64
- loadFromData
- loadFromFile
- loadFromFontIconCode
- loadFromResource
- resize
- resizeAsync
- saveToFile
- saveToFileAsync
- setNativeSource
- toBase64String
- toBase64StringAsync
Constructors
constructor
new ImageSource(nativeSource?: any): ImageSource
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.
Parameter | Default | Description |
nativeSource |
| any The native image object. Will be either a Bitmap for Android or a UIImage for iOS. |
Returns ImageSource
Properties
android
The Android-specific [image](http://developer.android.com/reference/android/graphics/Bitmap.html) instance. Will be undefined when running on iOS.
height
Gets the height of this instance. This is a read-only property.
ios
The iOS-specific [UIImage](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImage_Class/) instance. Will be undefined when running on Android.
rotationAngle
Gets or sets the rotation angle that should be applied to the image. (Used in android)
width
Gets the width of this instance. This is a read-only property.
Methods
fromAsset
fromAsset(asset: ImageAsset): Promise<ImageSource>
Parameter | Default | Description |
asset |
| The ImageAsset instance used to create ImageSource. |
Returns Promise<ImageSource>
fromBase64
Parameter | Default | Description |
source |
| string The Base64 string to load the image from. |
Returns Promise<boolean>
fromData
Parameter | Default | Description |
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
Parameter | Default | Description |
path |
| string The location of the file on the file system. |
Returns Promise<boolean>
fromResource
Parameter | Default | Description |
name |
| string The name of the resource (without its extension). |
Returns Promise<boolean>
loadFromBase64
Parameter | Default | Description |
source |
| string The Base64 string to load the image from. |
Returns boolean
loadFromData
Parameter | Default | Description |
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
Parameter | Default | Description |
path |
| string The location of the file on the file system. |
Returns boolean
loadFromFontIconCode
Returns boolean
loadFromResource
Parameter | Default | Description |
name |
| string The name of the resource (without its extension). |
Returns boolean
resize
resize(maxSize: number, options?: any): ImageSource
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.
Parameter | Default | Description |
maxSize |
| number The maximum pixel dimension of the resulting image. |
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
resizeAsync
resizeAsync(maxSize: number, options?: any): Promise<ImageSource>
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 asynchronously.
Parameter | Default | Description |
maxSize |
| number The maximum pixel dimension of the resulting image. |
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 Promise<ImageSource>
saveToFile
Saves this instance to the specified file, using the provided image format and quality.
Parameter | Default | Description |
path |
| string The path of the file on the file system to save to. |
format |
| "png" | "jpeg" | "jpg" The format (encoding) of the image. |
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
saveToFileAsync
saveToFileAsync(path: string, format: "png" | "jpeg" | "jpg", quality?: number): Promise<boolean>
Saves this instance to the specified file, using the provided image format and quality asynchronously.
Parameter | Default | Description |
path |
| string The path of the file on the file system to save to. |
format |
| "png" | "jpeg" | "jpg" The format (encoding) of the image. |
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 Promise<boolean>
setNativeSource
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.
Parameter | Default | Description |
nativeSource |
| any The native image object. Will be either a Bitmap for Android or a UIImage for iOS. |
Returns void
toBase64String
Converts the image to base64 encoded string, using the provided image format and quality.
Parameter | Default | Description |
format |
| "png" | "jpeg" | "jpg" The format (encoding) of the image. |
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
toBase64StringAsync
Converts the image to base64 encoded string, using the provided image format and quality asynchronously.
Parameter | Default | Description |
format |
| "png" | "jpeg" | "jpg" The format (encoding) of the image. |
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 Promise<string>
fromAsset
Static
fromAsset(asset: ImageAsset): Promise<ImageSource>
Loads this instance from the specified asset asynchronously.
Parameter | Default | Description |
asset |
| The ImageAsset instance used to create ImageSource. |
Returns Promise<ImageSource>
fromBase64
Static
fromBase64(source: string): Promise<ImageSource>
Loads this instance from the specified base64 encoded string asynchronously.
Parameter | Default | Description |
source |
| string The Base64 string to load the image from. |
Returns Promise<ImageSource>
fromBase64Sync
Static
fromBase64Sync(source: string): ImageSource
Loads this instance from the specified base64 encoded string.
Parameter | Default | Description |
source |
| string The Base64 string to load the image from. |
Returns ImageSource
fromData
Static
fromData(data: any): Promise<ImageSource>
Loads this instance from the specified native image data asynchronously.
Parameter | Default | Description |
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>
fromDataSync
Static
fromDataSync(data: any): ImageSource
Loads this instance from the specified native image data.
Parameter | Default | Description |
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
fromFile
Static
fromFile(path: string): Promise<ImageSource>
Loads this instance from the specified file asynchronously.
Parameter | Default | Description |
path |
| string The location of the file on the file system. |
Returns Promise<ImageSource>
fromFileOrResourceSync
Static
fromFileOrResourceSync(path: string): ImageSource
Creates a new ImageSource instance and loads it from the specified local file or resource (if specified with the "res://" prefix).
Parameter | Default | Description |
path |
| string The location of the file on the file system. |
Returns ImageSource
fromFileSync
Static
fromFileSync(path: string): ImageSource
Loads this instance from the specified file.
Parameter | Default | Description |
path |
| string The location of the file on the file system. |
Returns ImageSource
fromFontIconCodeSync
Static
fromFontIconCodeSync(source: string, font: Font, color: Color): ImageSource
Creates a new ImageSource instance and loads it from the specified font icon code.
Returns ImageSource
fromResource
Static
fromResource(name: string): Promise<ImageSource>
Loads this instance from the specified resource name asynchronously.
Parameter | Default | Description |
name |
| string The name of the resource (without its extension). |
Returns Promise<ImageSource>
fromResourceSync
Static
fromResourceSync(name: string): ImageSource
Loads this instance from the specified resource name.
Parameter | Default | Description |
name |
| string The name of the resource (without its extension). |
Returns ImageSource
fromUrl
Static
fromUrl(url: string): Promise<ImageSource>
Downloads the image from the provided Url and creates a new ImageSource instance from it.
Parameter | Default | Description |
url |
| string The link to the remote image object. This operation will download and decode the image. |
Returns Promise<ImageSource>
- Previous
- ImageCache
- Next
- InheritedCssProperty