update library/src/main/ets/downsampling/Downsampler.ets.
Signed-off-by: 田双明 <tianshuangming@h-partners.com>
This commit is contained in:
parent
ba95318b57
commit
647b2dc1f8
|
@ -18,11 +18,7 @@ import {
|
||||||
CenterOutside,
|
CenterOutside,
|
||||||
DownsampleStrategy,
|
DownsampleStrategy,
|
||||||
FitCenter,
|
FitCenter,
|
||||||
None,
|
|
||||||
} from './DownsampleStartegy';
|
} from './DownsampleStartegy';
|
||||||
import { highestOneBit, round, SampleSizeRounding } from './DownsampleUtils';
|
|
||||||
|
|
||||||
|
|
||||||
export class Downsampler {
|
export class Downsampler {
|
||||||
calculateScaling(
|
calculateScaling(
|
||||||
typeValue: string,
|
typeValue: string,
|
||||||
|
@ -39,22 +35,6 @@ export class Downsampler {
|
||||||
let downsampler = this.getDownsampler(downsampType);
|
let downsampler = this.getDownsampler(downsampType);
|
||||||
let scaleFactor: number =
|
let scaleFactor: number =
|
||||||
downsampler.getScaleFactor(sourceWidth, sourceHeight, requestWidth, requestHeight, downsampType);//缩放比
|
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") {
|
if (typeValue === "png") {
|
||||||
return {
|
return {
|
||||||
|
@ -80,8 +60,6 @@ export class Downsampler {
|
||||||
case DownsampleStrategy.FIT_CENTER_MEMORY:
|
case DownsampleStrategy.FIT_CENTER_MEMORY:
|
||||||
case DownsampleStrategy.FIT_CENTER_QUALITY:
|
case DownsampleStrategy.FIT_CENTER_QUALITY:
|
||||||
return new FitCenter();
|
return new FitCenter();
|
||||||
case DownsampleStrategy.NONE:
|
|
||||||
return new None();
|
|
||||||
case DownsampleStrategy.AT_MOST:
|
case DownsampleStrategy.AT_MOST:
|
||||||
return new AtMost();
|
return new AtMost();
|
||||||
case DownsampleStrategy.CENTER_INSIDE_MEMORY:
|
case DownsampleStrategy.CENTER_INSIDE_MEMORY:
|
||||||
|
|
Loading…
Reference in New Issue