Compare commits
3 Commits
f709bd3f01
...
a1e8e0b15f
Author | SHA1 | Date |
---|---|---|
|
a1e8e0b15f | |
|
1615da7b7c | |
|
3378d36046 |
|
@ -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
|
||||
|
|
|
@ -12,49 +12,47 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {
|
||||
ImageKnifeComponent,
|
||||
ImageKnifeData,
|
||||
ImageKnifeRequest, LogUtil
|
||||
} from '@ohos/libraryimageknife';
|
||||
import { ImageKnifeComponent } from '@ohos/libraryimageknife';
|
||||
import { display } from '@kit.ArkUI';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct AutoImageFit {
|
||||
@State width1: Length = '100%'
|
||||
@State imageWidth: number = 200;
|
||||
private maxWidth: number = px2vp(display.getDefaultDisplaySync().width);
|
||||
|
||||
build() {
|
||||
Scroll() {
|
||||
|
||||
Column() {
|
||||
this.Slider()
|
||||
Column() {
|
||||
Button($r('app.string.adjust_size')).onClick(() => {
|
||||
if (this.width1.toString() == '100%') {
|
||||
this.width1 = '60%'
|
||||
} else {
|
||||
this.width1 = '100%'
|
||||
}
|
||||
}).width('100%')
|
||||
Text('Image')
|
||||
Image('https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/56/v3/8MdhfSsCSMKj4sA6okUWrg/5uBx56tLTUO3RYQl-E5JiQ.jpg').width('100%').objectFit(ImageFit.Auto)
|
||||
Image('https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/56/v3/8MdhfSsCSMKj4sA6okUWrg/5uBx56tLTUO3RYQl-E5JiQ.jpg')
|
||||
.width('100%')
|
||||
.objectFit(ImageFit.Auto)
|
||||
Text('ImageKnife')
|
||||
ImageKnifeComponent({
|
||||
imageKnifeOption: {
|
||||
loadSrc: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/56/v3/8MdhfSsCSMKj4sA6okUWrg/5uBx56tLTUO3RYQl-E5JiQ.jpg',
|
||||
objectFit: ImageFit.Auto,
|
||||
onLoadListener: {
|
||||
onLoadStart: (request?: ImageKnifeRequest) => {
|
||||
LogUtil.info('onLoadStart')
|
||||
},
|
||||
onLoadSuccess: (data: string | PixelMap | undefined, imageKnifeData: ImageKnifeData,
|
||||
request?: ImageKnifeRequest) => {
|
||||
LogUtil.info('onLoadSuccess')
|
||||
}
|
||||
}
|
||||
}
|
||||
}).width('100%')
|
||||
|
||||
}.width(this.width1).border({ width: 1 })
|
||||
}.width(this.imageWidth).border({ width: 1 })
|
||||
}
|
||||
}
|
||||
|
||||
@Builder
|
||||
Slider() {
|
||||
Slider({
|
||||
value: this.imageWidth,
|
||||
min: 100,
|
||||
max: this.maxWidth,
|
||||
style: SliderStyle.OutSet
|
||||
})
|
||||
.blockColor(Color.White)
|
||||
.width('100%')
|
||||
.onChange((value: number) => {
|
||||
this.imageWidth = value;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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"
|
||||
},
|
||||
|
|
|
@ -192,7 +192,6 @@ export class FileCache {
|
|||
if (!this.isInited) {
|
||||
return
|
||||
}
|
||||
this.isInited = false
|
||||
this.lruCache.clear()
|
||||
this.currentMemory = 0;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue