提交 Downsampler 类 报错修改

This commit is contained in:
sijainguo 2024-04-26 22:20:29 +08:00
parent 22f79c3588
commit 9c40365fc4
1 changed files with 7 additions and 5 deletions

View File

@ -1,8 +1,8 @@
/* /*
* asdfasdfasdfasdfasdf*/ * asdfasdfasdfasdfasdf*/
import { CenterOutside, FitCenter, SampleSizeRounding } from './Downsamplestrategy'; import { CenterOutside, FitCenter, SampleSizeRounding } from './Downsamplestrategy';
import { FileTypeutil } from '../../utits/Fitetypeutit'; import { FileTypeUtil } from '../../utits/Fitetypeutit';
import { Request0ption } from '../../Requestoption'; import { RequestOption } from '../../Requestoption';
let TAG = 'downsampling' let TAG = 'downsampling'
export class Downsampler { export class Downsampler {
calculateScaling( calculateScaling(
@ -37,9 +37,10 @@ export class Downsampler {
let exactScaleFactor: number = 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 = Center0utside.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");
} }
@ -118,8 +119,9 @@ export class Downsampler {
round(value: number): number { round(value: number): number {
return Math.floor(value +0.5); return Math.floor(value +0.5);
} }
isRotationRequired(degreesToRotate: number): boolean{ isRotationRequired(degreesToRotate: number): boolean {
return degreesToRotate == 90 || degreesToRotate == 270; return degreesToRotate == 90 || degreesToRotate == 270;
}
// isScaling(options: ESObject): boolean { // isScaling(options: ESObject): boolean {
// return options.inTargetDensity >0 // return options.inTargetDensity >0
// && options.inDensity>0 // && options.inDensity>0
@ -135,4 +137,4 @@ export class Downsampler {
let difference = adjustedScaleFactor / scaleFactorWithError; let difference = adjustedScaleFactor / scaleFactorWithError;
return this.round(difference * targetDensity); return this.round(difference * targetDensity);
} }
} }