Image-source modules refactoring

This commit is contained in:
vakrilov
2015-03-13 15:03:18 +02:00
parent d5e16ec119
commit 36e0f80a10
14 changed files with 309 additions and 330 deletions

View File

@ -3,22 +3,7 @@
*/
declare module "image-source" {
/**
* Defines the recognized image formats.
*/
export enum ImageFormat {
/**
* The W3C Portable Network Graphics (PNG) image format.
*/
PNG,
/**
* The Joint Photographic Experts Group (JPEG) image format.
*/
JPEG,
}
/**
/**
* Encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images.
*/
export class ImageSource {
@ -73,14 +58,14 @@ declare module "image-source" {
* @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: ImageFormat, quality?: number): boolean;
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: ImageFormat, quality?: number): string;
toBase64String(format: string, quality?: number): string;
}
/**
@ -113,4 +98,10 @@ declare module "image-source" {
* @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;
}