demo报错修改
This commit is contained in:
parent
d680dcb9a0
commit
f99cd17cc4
|
@ -36,13 +36,13 @@ export class Downsampler {
|
||||||
orientedSourceHeight = sourceWidth;
|
orientedSourceHeight = sourceWidth;
|
||||||
}
|
}
|
||||||
/*安卓的模式*/
|
/*安卓的模式*/
|
||||||
let exactScaleFactor: number = new FitCenter().getScaleFactor(orientedSourceWidth, orientedSourceHeight, targetWidth, targetHeight)
|
let exactScaleFactor: number = FitCenter.getScaleFactor(orientedSourceWidth, orientedSourceHeight, targetWidth, targetHeight)
|
||||||
if (exactScaleFactor <= 0) {
|
if (exactScaleFactor <= 0) {
|
||||||
throw new Error("Cannot round with exactScaleFactor");
|
throw new Error("Cannot round with exactScaleFactor");
|
||||||
}
|
}
|
||||||
console.log('exactScaleFactor', exactScaleFactor)
|
console.log('exactScaleFactor', exactScaleFactor)
|
||||||
/*安卓的模式*/
|
/*安卓的模式*/
|
||||||
let rounding: SampleSizeRounding = new FitCenter().getSampleSizeRounding(orientedSourceWidth, orientedSourceHeight, targetWidth, targetHeight)
|
let rounding: SampleSizeRounding = CenterOutside.getSampleSizeRounding(orientedSourceWidth, orientedSourceHeight, targetWidth, targetHeight)
|
||||||
if (rounding == null) {
|
if (rounding == null) {
|
||||||
throw new Error("Cannot round with null rounding");
|
throw new Error("Cannot round with null rounding");
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ export class Downsampler {
|
||||||
let scaleFactor = rounding == SampleSizeRounding.MEMORY ? Math.max(widthScaleFactor, heightScaleFactor) : Math.min(widthScaleFactor, heightScaleFactor)
|
let scaleFactor = rounding == SampleSizeRounding.MEMORY ? Math.max(widthScaleFactor, heightScaleFactor) : Math.min(widthScaleFactor, heightScaleFactor)
|
||||||
// 将整型的缩放因子转换为2的次幂采样大小
|
// 将整型的缩放因子转换为2的次幂采样大小
|
||||||
let powerOfTwoSampleSize: number = 0;
|
let powerOfTwoSampleSize: number = 0;
|
||||||
|
powerOfTwoSampleSize = Math.max(1,this.highestOneBit(scaleFactor))
|
||||||
if (rounding == SampleSizeRounding.MEMORY && powerOfTwoSampleSize < (1 / exactScaleFactor)) {
|
if (rounding == SampleSizeRounding.MEMORY && powerOfTwoSampleSize < (1 / exactScaleFactor)) {
|
||||||
powerOfTwoSampleSize = powerOfTwoSampleSize << 1;
|
powerOfTwoSampleSize = powerOfTwoSampleSize << 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue