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

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

View File

@ -152,13 +152,11 @@ export class CenterInside implements BaseDownsampling {
width: round(Math.min(1, getScale(sourceWidth, sourceHeight, requestedWidth, requestedHeight, downsampType)) * sourceWidth),
height:round(Math.min(1, getScale(sourceWidth, sourceHeight, requestedWidth, requestedHeight, downsampType)) * sourceHeight)
}
//将整型的缩放因子转换为2的次幂采样大小
let scaleFactor = this.getSampleSizeType(sourceWidth, sourceHeight, requestedWidth, requestedHeight,
downsampType) == SampleSizeRounding.QUALITY ?
Math.max(sourceWidth / outSize.width, sourceHeight / outSize.height) :
Math.min(sourceWidth / outSize.width, sourceHeight / outSize.height) //重新计算宽高比
scaleFactor = Math.max(1, highestOneBit(scaleFactor))//将整型的缩放因子转换为2的次幂采样大小
Math.max(1, highestOneBit(Math.max(sourceWidth / outSize.width, sourceHeight / outSize.height))) :
Math.max(1, highestOneBit(Math.min(sourceWidth / outSize.width, sourceHeight / outSize.height)))
if (this.getSampleSizeType(sourceWidth, sourceHeight, requestedWidth, requestedHeight, downsampType)
== SampleSizeRounding.MEMORY && (scaleFactor < (1 / Math.min(1, getScale(sourceWidth, sourceHeight, requestedWidth, requestedHeight, downsampType))))) {
scaleFactor = scaleFactor << 1;