From 1615da7b7ced297359c97573ba368f36fe13ad6c Mon Sep 17 00:00:00 2001 From: zgf Date: Mon, 13 Jan 2025 14:49:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=9F=A9=E5=BD=A2=E8=A3=81=E5=89=AA=E5=BC=82=E5=B8=B8=E3=80=81?= =?UTF-8?q?=E6=B8=85=E9=99=A4=E6=96=87=E4=BB=B6=E7=BC=93=E5=AD=98=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=AF=BC=E8=87=B4=E6=96=87=E4=BB=B6=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zgf --- CHANGELOG.md | 4 ++++ entry/src/main/ets/pages/ImageTransformation.ets | 6 +++--- library/oh-package.json5 | 2 +- library/src/main/ets/cache/FileCache.ets | 1 - library/src/main/ets/transform/CropTransformation.ets | 7 ++++--- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c5c5cf..d33e7f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.2.1-rc.0 +- Fix bug: CropTransformation is used to crop the original image +- Fix bug: After calling the clear all file cache interfaces, the file cache becomes invalid + ## 3.2.0 - When successfully requesting the network, return the httpcode as well - Fix bug: Network error code httpCode returns no data diff --git a/entry/src/main/ets/pages/ImageTransformation.ets b/entry/src/main/ets/pages/ImageTransformation.ets index d085527..a500f07 100644 --- a/entry/src/main/ets/pages/ImageTransformation.ets +++ b/entry/src/main/ets/pages/ImageTransformation.ets @@ -398,13 +398,13 @@ struct ImageTransformation { transformations.push(new CropSquareTransformation()); } if (this.isCropTop) { - transformations.push(new CropTransformation(25, 25, 0)); + transformations.push(new CropTransformation(100, 100, 0)); } if (this.isCropCenter) { - transformations.push(new CropTransformation(25, 25, 1)); + transformations.push(new CropTransformation(100, 100, 1)); } if (this.isCropBottom) { - transformations.push(new CropTransformation(25, 25, 2)); + transformations.push(new CropTransformation(100, 100, 2)); } if (this.isSepia) { transformations.push(new SepiaTransformation()); diff --git a/library/oh-package.json5 b/library/oh-package.json5 index a3c232d..6bfe76b 100644 --- a/library/oh-package.json5 +++ b/library/oh-package.json5 @@ -14,7 +14,7 @@ "main": "index.ets", "repository": "https://gitee.com/openharmony-tpc/ImageKnife", "type": "module", - "version": "3.2.0", + "version": "3.2.1-rc.0", "dependencies": { "@ohos/gpu_transform": "^1.0.2" }, diff --git a/library/src/main/ets/cache/FileCache.ets b/library/src/main/ets/cache/FileCache.ets index 50a1d92..0cd1716 100644 --- a/library/src/main/ets/cache/FileCache.ets +++ b/library/src/main/ets/cache/FileCache.ets @@ -192,7 +192,6 @@ export class FileCache { if (!this.isInited) { return } - this.isInited = false this.lruCache.clear() this.currentMemory = 0; diff --git a/library/src/main/ets/transform/CropTransformation.ets b/library/src/main/ets/transform/CropTransformation.ets index 5337ecc..f3ecdd8 100644 --- a/library/src/main/ets/transform/CropTransformation.ets +++ b/library/src/main/ets/transform/CropTransformation.ets @@ -56,11 +56,12 @@ export class CropTransformation extends PixelMapTransformation { let scaledWidth: number = scale * pixelMapWidth; let scaledHeight: number = scale * pixelMapHeight; let left: number = (this.mWidth - scaledWidth) / 2; - let top: number = Math.abs(this.getTop(pixelMapHeight)); + let top: number = Math.abs(this.getTop(scaledHeight)); + toTransform.scaleSync(scale,scale) let region: image.Region = { size: { - width: scaledWidth > pixelMapWidth ? pixelMapWidth : scaledWidth, - height: scaledHeight > pixelMapHeight ? pixelMapHeight : scaledHeight + width: this.mWidth, + height: this.mHeight }, x: left < 0 ? 0 : left, y: top < 0 ? 0 : top