mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Image module reworked
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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
7
Image/image.d.ts
vendored
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
export enum ImageType {
|
||||
PNG = 0,
|
||||
JPEG = 1,
|
||||
}
|
||||
Reference in New Issue
Block a user