forked from NativeScript/NativeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage-source.d.ts
More file actions
125 lines (106 loc) · 5.19 KB
/
image-source.d.ts
File metadata and controls
125 lines (106 loc) · 5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**
* Contains the ImageSource class, which encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images.
*/
declare module "image-source" {
/**
* Encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images.
*/
export class ImageSource {
/**
* Gets the height of this instance. This is a read-only property.
*/
height: number;
/**
* Gets the width of this instance. This is a read-only property.
*/
width: number;
/**
* The iOS-specific [UIImage](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImage_Class/) instance. Will be undefined when running on Android.
*/
ios: UIImage;
/**
* The Android-specific [image](http://developer.android.com/reference/android/graphics/Bitmap.html) instance. Will be undefined when running on iOS.
*/
android: android.graphics.Bitmap;
/**
* Loads this instance from the specified resource name.
* @param name The name of the resource (without its extension).
*/
loadFromResource(name: string): boolean;
/**
* Loads this instance from the specified file.
* @param path The location of the file on the file system.
*/
loadFromFile(path: string): boolean;
/**
* Loads this instance from the specified native image data.
* @param data The native data (byte array) to load the image from. This will be either Stream for Android or NSData for iOS.
*/
loadFromData(data: any): boolean;
/**
* Loads this instance from the specified native image data.
* @param source The Base64 string to load the image from.
*/
loadFromBase64(source: string): boolean;
/**
* Sets the provided native source object (typically a Bitmap).
* This will update either the android or ios properties, depending on the target os.
* @param source The native image object. Will be either a Bitmap for Android or a UIImage for iOS.
*/
setNativeSource(source: any): boolean;
/**
* Saves this instance to the specified file, using the provided image format and quality.
* @param path The path of the file on the file system to save to.
* @param format The format (encoding) of the image.
* @param quality Optional parameter, specifying the quality of the encoding. Defaults to the maximum available quality.
*/
saveToFile(path: string, format: string, quality?: number): boolean;
/**
* Converts the image to base64 encoded string, using the provided image format and quality.
* @param format The format (encoding) of the image.
* @param quality Optional parameter, specifying the quality of the encoding. Defaults to the maximum available quality.
*/
toBase64String(format: string, quality?: number): string;
}
/**
* Creates a new ImageSource instance and loads it from the specified resource name.
* @param name The name of the resource (without its extension).
*/
export function fromResource(name: string): ImageSource;
/**
* Creates a new ImageSource instance and loads it from the specified file.
* @param path The location of the file on the file system.
*/
export function fromFile(path: string): ImageSource;
/**
* Creates a new ImageSource instance and loads it from the specified resource name.
* @param data The native data (byte array) to load the image from. This will be either Stream for Android or NSData for iOS.
*/
export function fromData(data: any): ImageSource;
/**
* Creates a new ImageSource instance and loads it from the specified resource name.
* @param source The Base64 string to load the image from.
*/
export function fromBase64(source: string): 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.
* @param source The native image object. Will be either a Bitmap for Android or a UIImage for iOS.
*/
export function fromNativeSource(source: any): ImageSource;
/**
* Downloads the image from the provided Url and creates a new ImageSource instance from it.
* @param url The link to the remote image object. This operation will download and decode the image.
*/
export function fromUrl(url: string): Promise<ImageSource>;
/**
* Creates a new ImageSource instance and loads it from the specified local file or resource(if spexified with "res://" prefix)
* @param path The location of the file on the file system.
*/
export function fromFileOrResource(path: string): ImageSource;
/**
* [Obsolete. Please use utils.isFileOrResourcePath instead!] Returns true if the specified path points to a resource or local file.
* @param path The path.
*/
export function isFileOrResourcePath(path: string): boolean
}