From 29e0df8d2b41e8e1edb062d53fcb87ffbb1d5380 Mon Sep 17 00:00:00 2001 From: tsm Date: Fri, 18 Oct 2024 18:16:42 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=8D=E9=87=87=E6=A0=B7=E5=8A=9Fdemo?= =?UTF-8?q?=E6=96=87=E5=AD=97=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tsm --- CHANGELOG.md | 4 ++-- entry/src/main/ets/pages/DownSamplePage.ets | 10 ++++++---- entry/src/main/resources/base/element/string.json | 12 ++++++++++++ entry/src/main/resources/zh_CN/element/string.json | 12 ++++++++++++ .../src/main/ets/downsampling/DownsampleStartegy.ets | 4 ++-- library/src/main/ets/downsampling/Downsampler.ets | 4 ++-- 6 files changed, 36 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78aa788..f0a8d36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ - +## 3.1.1-rc.1 +- Photo reduction sampling ## 3.1.1-rc.0 - 重构代码:抽取ImageKnifeDispatcher子线程requestJob相关代码到ImageKnifeLoader中,降低函数复杂度 -- 降采样功能 ## 3.1.0 - 部分静态webp图片有delay属性导致识别成动图,改用getFrameCount识别 - 修复加载错误图后未去请求排队队列中的请求 diff --git a/entry/src/main/ets/pages/DownSamplePage.ets b/entry/src/main/ets/pages/DownSamplePage.ets index aeaa9af..8a59b89 100644 --- a/entry/src/main/ets/pages/DownSamplePage.ets +++ b/entry/src/main/ets/pages/DownSamplePage.ets @@ -165,7 +165,9 @@ struct DownSamplePage { console.error("Failed to create PixelMap") }); } - + getResourceString(res:Resource){ + return getContext().resourceManager.getStringSync(res.id) + } build() { Scroll() { Column() { @@ -178,12 +180,12 @@ struct DownSamplePage { .onClick(() => { this.updateImageKnifeOption(item.value) }) - Text("降采样规格:" + item.value).fontSize(20) + Text(this.getResourceString($r('app.string.Sampling_pecification'))+ item.value).fontSize(20) } }, (item: SamplingType) => JSON.stringify(item)) Column() { - Text(`未降采样大小:${this.beforeSampling}`).fontSize(20) - Text(`降采样后大小:${this.afterSampling}`).fontSize(20) + Text(`${this.getResourceString($r('app.string.Unreal_samples'))}:${this.beforeSampling}`).fontSize(20) + Text(`${ this.getResourceString($r('app.string.After_the_sampling'))}:${this.afterSampling}`).fontSize(20) } ImageKnifeComponent({ diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index aff88e0..750b0c0 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -371,6 +371,18 @@ { "name": "Image_Downsampling_Functionality", "value": "Downscale Image effect" + }, + { + "name": "Sampling_pecification", + "value": "降采样规格" + }, + { + "name": "Unreal_samples", + "value": "未降采样大小" + }, + { + "name": "After_the_sampling", + "value": "降采样后大小" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json index bd30a41..698a69d 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -367,6 +367,18 @@ { "name": "Image_Downsampling_Functionality", "value": "降采样功能" + }, + { + "name": "Sampling_pecification", + "value": "降采样规格" + }, + { + "name": "Unreal_samples", + "value": "未降采样大小" + }, + { + "name": "After_the_sampling", + "value": "降采样后大小" } ] } \ No newline at end of file diff --git a/library/src/main/ets/downsampling/DownsampleStartegy.ets b/library/src/main/ets/downsampling/DownsampleStartegy.ets index 0446568..5e95a19 100644 --- a/library/src/main/ets/downsampling/DownsampleStartegy.ets +++ b/library/src/main/ets/downsampling/DownsampleStartegy.ets @@ -44,9 +44,9 @@ export class FitCenter implements BaseDownsampling { /*宽高进行等比缩放宽高里面最小的比例先放进去 然后再更据原图的缩放比去适配另一边*/ -export class CenterOutside implements BaseDownsampling { +export class AtLeast implements BaseDownsampling { getName() { - return "CenterOutside" + return "AtLeast" } getScaleFactor(sourceWidth: number, sourceHeight: number, requestedWidth: number, requestedHeight: number): number { diff --git a/library/src/main/ets/downsampling/Downsampler.ets b/library/src/main/ets/downsampling/Downsampler.ets index 2a0a49f..328e228 100644 --- a/library/src/main/ets/downsampling/Downsampler.ets +++ b/library/src/main/ets/downsampling/Downsampler.ets @@ -15,7 +15,7 @@ import { AtMost, CenterInside, - CenterOutside, + AtLeast, DownsampleStrategy, FitCenter, } from './DownsampleStartegy'; @@ -65,7 +65,7 @@ export class Downsampler { case DownsampleStrategy.CENTER_OUTSIDE_QUALITY: return new CenterInside(); case DownsampleStrategy.AT_LEAST: - return new CenterOutside(); + return new AtLeast(); default: throw new Error('Unsupported downsampling strategy'); }