update library/src/main/ets/downsampling/Downsampler.ets.

Signed-off-by: 田双明 <tianshuangming@h-partners.com>
This commit is contained in:
田双明 2024-10-10 08:19:15 +00:00 committed by Gitee
parent ba95318b57
commit 647b2dc1f8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 0 additions and 22 deletions

View File

@ -18,11 +18,7 @@ import {
CenterOutside,
DownsampleStrategy,
FitCenter,
None,
} from './DownsampleStartegy';
import { highestOneBit, round, SampleSizeRounding } from './DownsampleUtils';
export class Downsampler {
calculateScaling(
typeValue: string,
@ -39,22 +35,6 @@ export class Downsampler {
let downsampler = this.getDownsampler(downsampType);
let scaleFactor: number =
downsampler.getScaleFactor(sourceWidth, sourceHeight, requestWidth, requestHeight, downsampType);//缩放比
// let rounding: SampleSizeRounding =
// downsampler.getSampleSizeType(sourceWidth, sourceHeight, requestWidth, requestHeight, downsampType); //采样类型
//根据缩放比重新计算宽高
// let outSize: Size = {
// width: round(exactScaleFactor * sourceWidth),
// height:round(exactScaleFactor * sourceHeight)
// }
// let scaleFactor =
// rounding == SampleSizeRounding.QUALITY ? Math.max(sourceWidth / exactScaleFactor.width, sourceHeight / exactScaleFactor.height) :
// Math.min(sourceWidth / exactScaleFactor.width, sourceHeight / exactScaleFactor.height) //重新计算宽高比
// scaleFactor = Math.max(1, highestOneBit(scaleFactor))//将整型的缩放因子转换为2的次幂采样大小
//
// if (rounding == 0 && (scaleFactor < (1 / exactScaleFactor))) {
// scaleFactor = scaleFactor << 1;
// }
//基于上一步得出的采样大小,根据不同的图片类型,计算采样后的图片尺寸
if (typeValue === "png") {
return {
@ -80,8 +60,6 @@ export class Downsampler {
case DownsampleStrategy.FIT_CENTER_MEMORY:
case DownsampleStrategy.FIT_CENTER_QUALITY:
return new FitCenter();
case DownsampleStrategy.NONE:
return new None();
case DownsampleStrategy.AT_MOST:
return new AtMost();
case DownsampleStrategy.CENTER_INSIDE_MEMORY: