1 | import { ImageAsset } from '../image-asset';
|
2 | import { Font } from '../ui/styling/font';
|
3 | import { Color } from '../color';
|
4 |
|
5 |
|
6 |
|
7 | export class ImageSource {
|
8 | |
9 |
|
10 |
|
11 | height: number;
|
12 |
|
13 | |
14 |
|
15 |
|
16 | width: number;
|
17 |
|
18 | |
19 |
|
20 |
|
21 | rotationAngle: number;
|
22 |
|
23 | |
24 |
|
25 |
|
26 | ios: any ;
|
27 |
|
28 | |
29 |
|
30 |
|
31 | android: any ;
|
32 |
|
33 | |
34 |
|
35 |
|
36 |
|
37 | static fromAsset(asset: ImageAsset): Promise<ImageSource>;
|
38 |
|
39 | |
40 |
|
41 |
|
42 |
|
43 | static fromUrl(url: string): Promise<ImageSource>;
|
44 |
|
45 | |
46 |
|
47 |
|
48 |
|
49 | static fromResourceSync(name: string): ImageSource;
|
50 |
|
51 | |
52 |
|
53 |
|
54 |
|
55 | static fromResource(name: string): Promise<ImageSource>;
|
56 |
|
57 | |
58 |
|
59 |
|
60 |
|
61 | static iosSymbolScaleFor(scale: iosSymbolScaleType): number;
|
62 |
|
63 | |
64 |
|
65 |
|
66 |
|
67 | static fromSystemImageSync(name: string, scale?: iosSymbolScaleType): ImageSource;
|
68 |
|
69 | |
70 |
|
71 |
|
72 |
|
73 | static fromSystemImage(name: string, scale?: iosSymbolScaleType): Promise<ImageSource>;
|
74 |
|
75 | |
76 |
|
77 |
|
78 |
|
79 | static fromFileSync(path: string): ImageSource;
|
80 |
|
81 | |
82 |
|
83 |
|
84 |
|
85 | static fromFile(path: string): Promise<ImageSource>;
|
86 |
|
87 | |
88 |
|
89 |
|
90 |
|
91 | static fromFileOrResourceSync(path: string): ImageSource;
|
92 |
|
93 | |
94 |
|
95 |
|
96 |
|
97 | static fromDataSync(data: any): ImageSource;
|
98 |
|
99 | |
100 |
|
101 |
|
102 |
|
103 | static fromData(data: any): Promise<ImageSource>;
|
104 |
|
105 | |
106 |
|
107 |
|
108 |
|
109 | static fromBase64Sync(source: string): ImageSource;
|
110 |
|
111 | |
112 |
|
113 |
|
114 |
|
115 | static fromBase64(source: string): Promise<ImageSource>;
|
116 |
|
117 | |
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 | static fromFontIconCodeSync(source: string, font: Font, color: Color): ImageSource;
|
124 |
|
125 | |
126 |
|
127 |
|
128 |
|
129 |
|
130 | constructor(nativeSource?: any);
|
131 |
|
132 | /**
|
133 | * @deprecated Use ImageSource.fromAsset() instead.
|
134 | * Loads this instance from the specified asset asynchronously.
|
135 | * @param asset The ImageAsset instance used to create ImageSource.
|
136 | */
|
137 | fromAsset(asset: ImageAsset): Promise<ImageSource>;
|
138 |
|
139 | /**
|
140 | * @deprecated Use ImageSource.fromResourceSync() instead.
|
141 | * Loads this instance from the specified resource name.
|
142 | * @param name The name of the resource (without its extension).
|
143 | */
|
144 | loadFromResource(name: string): boolean;
|
145 |
|
146 | /**
|
147 | * @deprecated Use ImageSource.fromResource() instead.
|
148 | * Loads this instance from the specified resource name asynchronously.
|
149 | * @param name The name of the resource (without its extension).
|
150 | */
|
151 | fromResource(name: string): Promise<boolean>;
|
152 |
|
153 | /**
|
154 | * @deprecated Use ImageSource.fromFileSync() instead.
|
155 | * Loads this instance from the specified file.
|
156 | * @param path The location of the file on the file system.
|
157 | */
|
158 | loadFromFile(path: string): boolean;
|
159 |
|
160 | /**
|
161 | * @deprecated Use ImageSource.fromFile() instead.
|
162 | * Loads this instance from the specified file asynchronously.
|
163 | * @param path The location of the file on the file system.
|
164 | */
|
165 | fromFile(path: string): Promise<boolean>;
|
166 |
|
167 | /**
|
168 | * @deprecated Use ImageSource.fromDataSync() instead.
|
169 | * Loads this instance from the specified native image data.
|
170 | * @param data The native data (byte array) to load the image from. This will be either Stream for Android or NSData for iOS.
|
171 | */
|
172 | loadFromData(data: any): boolean;
|
173 |
|
174 | /**
|
175 | * @deprecated Use ImageSource.fromData() instead.
|
176 | * Loads this instance from the specified native image data asynchronously.
|
177 | * @param data The native data (byte array) to load the image from. This will be either Stream for Android or NSData for iOS.
|
178 | */
|
179 | fromData(data: any): Promise<boolean>;
|
180 |
|
181 | /**
|
182 | * @deprecated Use ImageSource.fromBase64Sync() instead.
|
183 | * Loads this instance from the specified base64 encoded string.
|
184 | * @param source The Base64 string to load the image from.
|
185 | */
|
186 | loadFromBase64(source: string): boolean;
|
187 |
|
188 | /**
|
189 | * @deprecated Use ImageSource.fromBase64() instead.
|
190 | * Loads this instance from the specified base64 encoded string asynchronously.
|
191 | * @param source The Base64 string to load the image from.
|
192 | */
|
193 | fromBase64(source: string): Promise<boolean>;
|
194 |
|
195 | /**
|
196 | * @deprecated Use ImageSource.fromFontIconCode() instead.
|
197 | * Loads this instance from the specified font icon code.
|
198 | * @param source The hex font icon code string
|
199 | * @param font The font for the corresponding font icon code
|
200 | * @param color The color of the generated icon image
|
201 | */
|
202 | loadFromFontIconCode(source: string, font: Font, color: Color): boolean;
|
203 |
|
204 | /**
|
205 | * Sets the provided native source object (typically a Bitmap or a UIImage).
|
206 | * This will update either the android or ios properties, depending on the target os.
|
207 | * @param nativeSource The native image object. Will be either a Bitmap for Android or a UIImage for iOS.
|
208 | */
|
209 | setNativeSource(nativeSource: any): void;
|
210 |
|
211 | /**
|
212 | * Saves this instance to the specified file, using the provided image format and quality.
|
213 | * @param path The path of the file on the file system to save to.
|
214 | * @param format The format (encoding) of the image.
|
215 | * @param quality Optional parameter, specifying the quality of the encoding. Defaults to the maximum available quality. Quality varies on a scale of 0 to 100.
|
216 | */
|
217 | saveToFile(path: string, format: 'png' | 'jpeg' | 'jpg', quality?: number): boolean;
|
218 |
|
219 | /**
|
220 | * Saves this instance to the specified file, using the provided image format and quality asynchronously.
|
221 | * @param path The path of the file on the file system to save to.
|
222 | * @param format The format (encoding) of the image.
|
223 | * @param quality Optional parameter, specifying the quality of the encoding. Defaults to the maximum available quality. Quality varies on a scale of 0 to 100.
|
224 | */
|
225 | saveToFileAsync(path: string, format: 'png' | 'jpeg' | 'jpg', quality?: number): Promise<boolean>;
|
226 |
|
227 | /**
|
228 | * Converts the image to base64 encoded string, using the provided image format and quality.
|
229 | * @param format The format (encoding) of the image.
|
230 | * @param quality Optional parameter, specifying the quality of the encoding. Defaults to the maximum available quality. Quality varies on a scale of 0 to 100.
|
231 | */
|
232 | toBase64String(format: 'png' | 'jpeg' | 'jpg', quality?: number): string;
|
233 |
|
234 | /**
|
235 | * Converts the image to base64 encoded string, using the provided image format and quality asynchronously.
|
236 | * @param format The format (encoding) of the image.
|
237 | * @param quality Optional parameter, specifying the quality of the encoding. Defaults to the maximum available quality. Quality varies on a scale of 0 to 100.
|
238 | */
|
239 | toBase64StringAsync(format: 'png' | 'jpeg' | 'jpg', quality?: number): Promise<string>;
|
240 |
|
241 | /**
|
242 | * 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.
|
243 | * @param maxSize The maximum pixel dimension of the resulting image.
|
244 | * @param options Optional parameter, Only used for android, options.filter is a boolean which
|
245 | * determines whether or not bilinear filtering should be used when scaling the bitmap.
|
246 | * If this is true then bilinear filtering will be used when scaling which has
|
247 | * better image quality at the cost of worse performance. If this is false then
|
248 | * nearest-neighbor scaling is used instead which will have worse image quality
|
249 | * but is faster. Recommended default is to set filter to 'true' as the cost of
|
250 | * bilinear filtering is typically minimal and the improved image quality is significant.
|
251 | */
|
252 | resize(maxSize: number, options?: any): ImageSource;
|
253 |
|
254 | /**
|
255 | * 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.
|
256 | * @param maxSize The maximum pixel dimension of the resulting image.
|
257 | * @param options Optional parameter, Only used for android, options.filter is a boolean which
|
258 | * determines whether or not bilinear filtering should be used when scaling the bitmap.
|
259 | * If this is true then bilinear filtering will be used when scaling which has
|
260 | * better image quality at the cost of worse performance. If this is false then
|
261 | * nearest-neighbor scaling is used instead which will have worse image quality
|
262 | * but is faster. Recommended default is to set filter to 'true' as the cost of
|
263 | * bilinear filtering is typically minimal and the improved image quality is significant.
|
264 | */
|
265 | resizeAsync(maxSize: number, options?: any): Promise<ImageSource>;
|
266 | }
|
267 |
|
268 | /**
|
269 | * iOS only
|
270 | * SF Symbol scale
|
271 | */
|
272 | export type iosSymbolScaleType = 'default' | 'small' | 'medium' | 'large';
|
273 |
|
274 | /**
|
275 | * @deprecated Use ImageSource.fromAsset() instead.
|
276 | * Creates a new ImageSource instance and loads it from the specified image asset asynchronously.
|
277 | * @param asset The image asset.
|
278 | */
|
279 | export function fromAsset(asset: ImageAsset): Promise<ImageSource>;
|
280 |
|
281 | /**
|
282 | * @deprecated Use ImageSource.fromResourceSync() instead.
|
283 | * Creates a new ImageSource instance and loads it from the specified resource name.
|
284 | * @param name The name of the resource (without its extension).
|
285 | */
|
286 | export function fromResource(name: string): ImageSource;
|
287 |
|
288 | /**
|
289 | * @deprecated Use ImageSource.fromFileSync() instead.
|
290 | * Creates a new ImageSource instance and loads it from the specified file.
|
291 | * @param path The location of the file on the file system.
|
292 | */
|
293 | export function fromFile(path: string): ImageSource;
|
294 |
|
295 | /**
|
296 | * @deprecated Use ImageSource.fromDataSync() instead.
|
297 | * Creates a new ImageSource instance and loads it from the specified native image data.
|
298 | * @param data The native data (byte array) to load the image from. This will be either Stream for Android or NSData for iOS.
|
299 | */
|
300 | export function fromData(data: any): ImageSource;
|
301 |
|
302 | /**
|
303 | * @deprecated Use ImageSource.fromBase64Sync() instead.
|
304 | * Creates a new ImageSource instance and loads it from the specified base64 encoded string.
|
305 | * @param source The base64 encoded string to load the image from.
|
306 | */
|
307 | export function fromBase64(source: string): ImageSource;
|
308 |
|
309 | /**
|
310 | * @deprecated Use ImageSource constructor instead.
|
311 | * Creates a new ImageSource instance and sets the provided native source object (typically a Bitmap).
|
312 | * The native source object will update either the android or ios properties, depending on the target os.
|
313 | * @param source The native image object. Will be either a Bitmap for Android or a UIImage for iOS.
|
314 | */
|
315 | export function fromNativeSource(source: any): ImageSource;
|
316 |
|
317 | /**
|
318 | * @deprecated Use ImageSource.fromFontIconCodeSync() instead.
|
319 | * Creates a new ImageSource instance and loads it from the specified font icon code.
|
320 | * @param source The hex font icon code string
|
321 | * @param font The font for the corresponding font icon code
|
322 | * @param color The color of the generated icon image
|
323 | */
|
324 | export function fromFontIconCode(source: string, font: Font, color: Color): ImageSource;
|
325 |
|
326 | /**
|
327 | * @deprecated Use ImageSource.fromUrl() instead.
|
328 | * Downloads the image from the provided Url and creates a new ImageSource instance from it.
|
329 | * @param url The link to the remote image object. This operation will download and decode the image.
|
330 | */
|
331 | export function fromUrl(url: string): Promise<ImageSource>;
|
332 |
|
333 | /**
|
334 | * @deprecated Use ImageSource.fromFileOrResourceSync() instead.
|
335 | * Creates a new ImageSource instance and loads it from the specified local file or resource (if specified with the "res:
|
336 | * @param path The location of the file on the file system.
|
337 | */
|
338 | export function fromFileOrResource(path: string): ImageSource;
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 | export function isFileOrResourcePath(path: string): boolean;
|
346 |
|
\ | No newline at end of file |