Image module reworked

This commit is contained in:
Vladimir Enchev
2014-03-24 14:05:49 +02:00
parent 1b6fdae4a9
commit f70b530f8a
5 changed files with 12 additions and 16 deletions

View File

@@ -108,9 +108,6 @@
<TypeScriptCompile Include="Image\image.android.ts">
<DependentUpon>image.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="Image\image_types.ts">
<DependentUpon>image.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="Image\image.d.ts" />
<TypeScriptCompile Include="Location\location.android.ts">
<DependentUpon>location.d.ts</DependentUpon>

View File

@@ -1,5 +1,5 @@
import app_module = require("Application/application");
import types_module = require("Image/image_types");
import image_module = require("Image/image");
export class Image {
public android: any;
@@ -36,11 +36,11 @@ export class Image {
return (this.android != null);
}
public saveToFile(path: string, format: types_module.ImageType, quality?: number): boolean {
public saveToFile(path: string, format: image_module.ImageType, quality?: number): boolean {
if (this.android) {
var targetFormat = android.graphics.Bitmap.CompressFormat.PNG;
switch (format) {
case types_module.ImageType.JPEG:
case image_module.ImageType.JPEG:
targetFormat = android.graphics.Bitmap.CompressFormat.JPEG;
break;
}

7
Image/image.d.ts vendored
View File

@@ -1,11 +1,14 @@
import types_module = require("Image/image_types");
export declare enum ImageType {
PNG = 0,
JPEG = 1,
}
export declare class Image {
loadFromResource(name: string): boolean;
loadFromFile(path: string): boolean;
loadFromData(data: any): boolean;
loadFromBitmap(source: any): boolean;
saveToFile(path: string, format: types_module.ImageType, quality?: number): boolean;
saveToFile(path: string, format: ImageType, quality?: number): boolean;
getHeight(): number;
getWidth(): number;

View File

@@ -1,4 +1,4 @@
import types_module = require("Image/image_types");
import image_module = require("Image/image");
export class Image {
public ios: any;
@@ -27,17 +27,17 @@ export class Image {
return (this.ios != null);
}
public saveToFile(path: string, format: types_module.ImageType, quality?: number): boolean {
public saveToFile(path: string, format: image_module.ImageType, quality?: number): boolean {
if (null == this.ios) {
return false;
}
var res = false;
var data = null;
switch (format) {
case types_module.ImageType.JPEG:
case image_module.ImageType.JPEG:
data = UIKit.UIImageJPEGRepresentation(this.ios, ('undefined' == typeof quality) ? 1.0 : quality);
break;
case types_module.ImageType.PNG:
case image_module.ImageType.PNG:
data = UIKit.UIImagePNGRepresentation(this.ios);
break;
}

View File

@@ -1,4 +0,0 @@
export enum ImageType {
PNG = 0,
JPEG = 1,
}