本文整理匯總了TypeScript中tns-core-modules/image-source.ImageSource.fromAsset方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ImageSource.fromAsset方法的具體用法?TypeScript ImageSource.fromAsset怎麽用?TypeScript ImageSource.fromAsset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tns-core-modules/image-source.ImageSource
的用法示例。
在下文中一共展示了ImageSource.fromAsset方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: imageSourceFromAsset
export function imageSourceFromAsset(imageAsset){
let source = new imageSource.ImageSource();
source.fromAsset(imageAsset).then((source) => {
let folder = fs.knownFolders.documents().path;
let fileName = "test.png"
let path = fs.path.join(folder, fileName);
let saved = source.saveToFile(path, "png");
if(saved){
console.log("saved image")
}
})
}
示例2:
.then((imageAsset) => {
let source = new imageSource.ImageSource();
source.fromAsset(imageAsset).then((source) => {
this.imageCropper.show(source,{width:100,height:100}).then((args) => {
if(args.image !== null){
this.imageUrl = args.image;
}
})
.catch(function(e){
console.log(e);
});
});
}).catch((err) => {
示例3: constructor
constructor() {
super();
let asset = new imageAssetModule.ImageAsset("~/splashscreen.png");
asset.options = {
width: 300,
height: 300,
keepAspectRatio: true
};
let source = new ImageSource();
source.fromAsset(asset).then((source) => {
this.set("cameraImageAsset", asset);
this.set("cameraImageSrc", source);
}, (error) => {
console.log(error);
});
}