修改uuid的生成方式,使用资源loadSrc,宽高以及转换效果的拼接字符串作为入参,修复同资源图形转换错乱的问题。
Signed-off-by: chongtiantian <chongtiantian1@h-partners.com>
This commit is contained in:
parent
db1ccdc604
commit
e48600fe7f
|
@ -1,5 +1,6 @@
|
||||||
## 2.3.0-rc.1
|
## 2.3.0-rc.1
|
||||||
- 修复file://格式图片无法显示
|
- 修复file://格式图片无法显示
|
||||||
|
- 修改uuid的生成方式,使用资源loadSrc,宽高以及转换效果的拼接字符串作为入参, 修复同资源图形转换错乱的问题
|
||||||
|
|
||||||
## 2.3.0-rc.0
|
## 2.3.0-rc.0
|
||||||
- 增加gif图duration的默认值,以及默认播放次数
|
- 增加gif图duration的默认值,以及默认播放次数
|
||||||
|
|
|
@ -47,6 +47,12 @@ struct transformsPage {
|
||||||
placeholderSrc: $r('app.media.icon_loading'),
|
placeholderSrc: $r('app.media.icon_loading'),
|
||||||
errorholderSrc: $r('app.media.icon_failed')
|
errorholderSrc: $r('app.media.icon_failed')
|
||||||
};
|
};
|
||||||
|
@State option1: ImageKnifeOption = {
|
||||||
|
loadSrc: $r('app.media.pngSample'),
|
||||||
|
}
|
||||||
|
@State option2: ImageKnifeOption = {
|
||||||
|
loadSrc: $r('app.media.pngSample'),
|
||||||
|
}
|
||||||
private transformations: Array<BaseTransform<PixelMap>> = new Array();
|
private transformations: Array<BaseTransform<PixelMap>> = new Array();
|
||||||
private blurTransformation: BlurTransformation = new BlurTransformation(15, 3);
|
private blurTransformation: BlurTransformation = new BlurTransformation(15, 3);
|
||||||
private brightnessFilterTransformation: BrightnessFilterTransformation = new BrightnessFilterTransformation(0.5);
|
private brightnessFilterTransformation: BrightnessFilterTransformation = new BrightnessFilterTransformation(0.5);
|
||||||
|
@ -452,6 +458,33 @@ struct transformsPage {
|
||||||
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||||
ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption }).width(300).height(300)
|
ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption }).width(300).height(300)
|
||||||
}.width(400).height(400).margin({ top: 10 }).backgroundColor(Color.Pink)
|
}.width(400).height(400).margin({ top: 10 }).backgroundColor(Color.Pink)
|
||||||
|
|
||||||
|
Button("同资源不同转换效果").onClick(() => {
|
||||||
|
this.option1 = {
|
||||||
|
loadSrc: $r('app.media.pngSample'),
|
||||||
|
errorholderSrc: $r("app.media.app_icon"),
|
||||||
|
transformation: new CropCircleTransformation()
|
||||||
|
}
|
||||||
|
this.option2 = {
|
||||||
|
loadSrc: $r('app.media.pngSample'),
|
||||||
|
errorholderSrc: $r("app.media.app_icon"),
|
||||||
|
transformations: [new RotateImageTransformation(45), new InvertFilterTransformation()]
|
||||||
|
}
|
||||||
|
}).margin(10).backgroundColor(Color.Blue)
|
||||||
|
Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center}) {
|
||||||
|
ImageKnifeComponent({
|
||||||
|
imageKnifeOption: this.option1
|
||||||
|
}).width(300)
|
||||||
|
.height(300)
|
||||||
|
.margin(10)
|
||||||
|
.borderWidth(3)
|
||||||
|
ImageKnifeComponent({
|
||||||
|
imageKnifeOption: this.option2
|
||||||
|
}).width(300)
|
||||||
|
.height(300)
|
||||||
|
.margin(10)
|
||||||
|
.borderWidth(3)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.width('100%')
|
.width('100%')
|
||||||
|
|
|
@ -404,11 +404,12 @@ export struct ImageKnifeComponent {
|
||||||
this.lastSrc = this.imageKnifeOption.loadSrc;
|
this.lastSrc = this.imageKnifeOption.loadSrc;
|
||||||
}
|
}
|
||||||
this.detachFromLayout = this.request.detachFromLayout;
|
this.detachFromLayout = this.request.detachFromLayout;
|
||||||
|
// 先配置request的属性
|
||||||
|
this.configDisplay(this.request);
|
||||||
if (this.request.loadSrc!=this.lastSrc) {
|
if (this.request.loadSrc!=this.lastSrc) {
|
||||||
this.configNecessary(this.request);
|
this.configNecessary(this.request);
|
||||||
}
|
}
|
||||||
this.configCacheStrategy(this.request);
|
this.configCacheStrategy(this.request);
|
||||||
this.configDisplay(this.request);
|
|
||||||
this.configHspContext(this.request);
|
this.configHspContext(this.request);
|
||||||
this.configRenderGpu(this.request);
|
this.configRenderGpu(this.request);
|
||||||
let imageKnife: ImageKnife | undefined = ImageKnifeGlobal?.getInstance()?.getImageKnife();
|
let imageKnife: ImageKnife | undefined = ImageKnifeGlobal?.getInstance()?.getImageKnife();
|
||||||
|
|
|
@ -208,7 +208,11 @@ export class RequestOption {
|
||||||
this.transformations = array;
|
this.transformations = array;
|
||||||
}
|
}
|
||||||
generateUUID(): string {
|
generateUUID(): string {
|
||||||
return SparkMD5.hashBinary(JSON.stringify(this.loadSrc)) as string;
|
let content: string = JSON.stringify(this.loadSrc) + ',' + this.size.width + ',' + this.size.height;
|
||||||
|
if (this.transformations.length) {
|
||||||
|
content += JSON.stringify(this.transformations);
|
||||||
|
}
|
||||||
|
return SparkMD5.hashBinary(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
setModuleContext(moduleCtx: common.UIAbilityContext) {
|
setModuleContext(moduleCtx: common.UIAbilityContext) {
|
||||||
|
|
Loading…
Reference in New Issue