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

Signed-off-by: 田双明 <tianshuangming@h-partners.com>
This commit is contained in:
田双明 2024-10-10 09:07:38 +00:00 committed by Gitee
parent c79046f005
commit d2646b5ad4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 1 additions and 12 deletions

View File

@ -101,7 +101,6 @@ export class CenterInside implements BaseDownsampling {
getScaleFactor(sourceWidth: number, sourceHeight: number, requestedWidth: number, requestedHeight: number, getScaleFactor(sourceWidth: number, sourceHeight: number, requestedWidth: number, requestedHeight: number,
downsampType: DownsampleStrategy downsampType: DownsampleStrategy
): number { ): number {
let outSize: Size = { let outSize: Size = {
width: round(Math.min(1, getScale(sourceWidth, sourceHeight, requestedWidth, requestedHeight, downsampType)) * sourceWidth), width: round(Math.min(1, getScale(sourceWidth, sourceHeight, requestedWidth, requestedHeight, downsampType)) * sourceWidth),
height:round(Math.min(1, getScale(sourceWidth, sourceHeight, requestedWidth, requestedHeight, downsampType)) * sourceHeight) height:round(Math.min(1, getScale(sourceWidth, sourceHeight, requestedWidth, requestedHeight, downsampType)) * sourceHeight)
@ -127,17 +126,7 @@ export class CenterInside implements BaseDownsampling {
return SampleSizeRounding.QUALITY return SampleSizeRounding.QUALITY
} }
//否则,使用 FIL_CENTER 的 SampleSizeRounding 值 //否则,使用 FIL_CENTER 的 SampleSizeRounding 值
return this.getSampleSize(sourceWidth, sourceHeight, requestedWidth, requestedHeight, downsampType); return downsampType === DownsampleStrategy.CENTER_INSIDE_MEMORY?SampleSizeRounding.MEMORY:SampleSizeRounding.QUALITY
}
getSampleSize(sourceWidth: number, sourceHeight: number, requestedWidth: number, requestedHeight: number,
downsampType: DownsampleStrategy
): SampleSizeRounding {
if (downsampType === DownsampleStrategy.CENTER_INSIDE_MEMORY) {
return SampleSizeRounding.MEMORY;
} else {
return SampleSizeRounding.QUALITY;
}
} }
} }