mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(image-asset-ios): add autoScaleFactor option to switch auto scaling (#6127)
This commit is contained in:
committed by
GitHub
parent
7e89f942b4
commit
81e63ee19e
@@ -111,20 +111,37 @@ export function testFromAssetSimple(done) {
|
||||
});
|
||||
}
|
||||
|
||||
export function testFromAssetWithScaling(done) {
|
||||
export function testFromAssetWithExactScaling(done) {
|
||||
let asset = new imageAssetModule.ImageAsset(splashscreenPath);
|
||||
let scaleWidth = 10;
|
||||
let scaleHeight = 11;
|
||||
asset.options = {
|
||||
width: scaleWidth,
|
||||
height: scaleHeight,
|
||||
keepAspectRatio: false
|
||||
keepAspectRatio: false,
|
||||
autoScaleFactor: false
|
||||
};
|
||||
|
||||
let img = imageSource.fromAsset(asset).then((source) => {
|
||||
imageSource.fromAsset(asset).then((source) => {
|
||||
TKUnit.assertEqual(source.width, scaleWidth);
|
||||
TKUnit.assertEqual(source.height, scaleHeight);
|
||||
done();
|
||||
|
||||
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) => {
|
||||
done(error);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user