修复自定义矩形裁剪异常、清除文件缓存接口导致文件缓存失效

Signed-off-by: zgf <zenggaofeng2@h-partners.com>
This commit is contained in:
zgf 2025-01-13 14:49:46 +08:00
parent 3378d36046
commit 1615da7b7c
5 changed files with 12 additions and 8 deletions

View File

@ -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

View File

@ -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());

View File

@ -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"
},

View File

@ -192,7 +192,6 @@ export class FileCache {
if (!this.isInited) {
return
}
this.isInited = false
this.lruCache.clear()
this.currentMemory = 0;

View File

@ -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