本文整理汇总了TypeScript中tns-core-modules/image-source.ImageSource.fromFile方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ImageSource.fromFile方法的具体用法?TypeScript ImageSource.fromFile怎么用?TypeScript ImageSource.fromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tns-core-modules/image-source.ImageSource
的用法示例。
在下文中一共展示了ImageSource.fromFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: done
imageSource.fromAsset(asset).then((source) => {
TKUnit.assertEqual(source.width, scaleWidth);
TKUnit.assertEqual(source.height, scaleHeight);
const targetFilename = `splashscreenTemp.png`;
const tempPath = fs.knownFolders.temp().path;
const localFullPath = fs.path.join(tempPath, targetFilename);
const fullImageSaved = source.saveToFile(localFullPath, "png");
if (fullImageSaved) {
let sourceImage = new imageSource.ImageSource();
sourceImage.fromFile(localFullPath).then(() => {
TKUnit.assertEqual(sourceImage.width, scaleWidth);
TKUnit.assertEqual(sourceImage.height, scaleHeight);
done();
});
} else {
done(`Error saving photo to local temp folder: ${localFullPath}`);
}
}, (error) => {
示例2: onSrcPropertySet
public static onSrcPropertySet(nativeWrapper, value) {
let image = nativeWrapper,
placeholder = nativeWrapper.placeholder,
placeholderImage = this.getPlaceholderUIImage(placeholder);
if (types.isString(value)) {
value = value.trim();
if (0 === value.indexOf("http")) {
image.isLoading = true;
image.nativeView.sd_setImageWithURLPlaceholderImageCompleted(value, placeholderImage, function() {
image.isLoading = false;
});
} else if (utils.isFileOrResourcePath(value)) {
image.isLoading = true;
let source: any = new imageSource.ImageSource();
if (0 === value.indexOf(utils.RESOURCE_PREFIX)) {
let path = value.substr(utils.RESOURCE_PREFIX.length);
source.fromResource(path).then(function() {
image.isLoading = false;
image.nativeView.image = source.ios || source.nativeView;
});
} else {
source.fromFile(value).then(function() {
image.isLoading = false;
image.nativeView.image = source.ios || source.nativeView;
});
}
}
image.requestLayout();
}
}