Pre Merge pull request !91 from 梁大志/master

This commit is contained in:
梁大志 2023-12-26 09:40:08 +00:00 committed by Gitee
commit 2dbc371109
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 75 additions and 1 deletions

View File

@ -286,6 +286,13 @@ struct IndexFunctionDemo {
router.pushUrl({ url: "pages/testManyGifLoadWithPage" }); router.pushUrl({ url: "pages/testManyGifLoadWithPage" });
}).margin({ top: 5, left: 3 }) }).margin({ top: 5, left: 3 })
}.width('100%').height(60).backgroundColor(Color.Pink) }.width('100%').height(60).backgroundColor(Color.Pink)
Text('测试图片抗锯齿').fontSize(15)
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Button('测试图片抗锯齿')
.onClick(() => {
router.pushUrl({ url: 'pages/testImageAntiAliasingWithPage' });
}).margin({ top: 5, left: 3 })
}.width('100%').height(60).backgroundColor(Color.Pink)
} }
} }
.width('100%') .width('100%')

View File

@ -0,0 +1,63 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ImageKnifeComponent } from '@ohos/libraryimageknife'
import { ImageKnifeOption } from '@ohos/libraryimageknife'
import { RotateImageTransformation } from '@ohos/libraryimageknife'
import { RoundedCornersTransformation } from '@ohos/libraryimageknife'
@Entry
@Component
struct TestImageAntiAliasingWithPage {
@State imageKnifeOption1: ImageKnifeOption =
{
loadSrc: "https://thirdwx.qlogo.cn/mmopen/xxxxx",
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
};
@State imageKnifeOption: ImageKnifeOption =
{
loadSrc: "https://hbimg.huabanimg.com/xxxxx",
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
};
@State imageKnifeOption3: ImageKnifeOption =
{
loadSrc: "https://hbimg.huabanimg.com/xxxxx",
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
};
@State imageKnifeOption4: ImageKnifeOption =
{
loadSrc: "https://hbimg.huabanimg.com/xxxxx",
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
};
build() {
Scroll() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption1 }).width(600).height(600)
Image($r('app.media.icon_failed'))
.width(600)
.height(600)
.margin(15)
.overlay('png', { align: Alignment.Bottom, offset: { x: 0, y: 20 } })
.interpolation(ImageInterpolation.High)
}
}
.width('100%')
.height('100%')
}
}

View File

@ -33,6 +33,7 @@
"pages/SignatureTestPage", "pages/SignatureTestPage",
"pages/hspCacheTestPage", "pages/hspCacheTestPage",
"pages/testManyNetImageLoadWithPage", "pages/testManyNetImageLoadWithPage",
"pages/testManyGifLoadWithPage" "pages/testManyGifLoadWithPage",
"pages/testImageAntiAliasingWithPage"
] ]
} }

View File

@ -115,6 +115,9 @@ export struct ImageKnifeComponent {
} }
}) })
.onReady(() => { .onReady(() => {
let ctx = this.context;
ctx.imageSmoothingEnabled = true;
ctx.imageSmoothingQuality = 'high';
this.canvasHasReady = true; this.canvasHasReady = true;
if (this.onReadyNext) { if (this.onReadyNext) {
LogUtil.log('ImageKnifeComponent onReadyNext is running!') LogUtil.log('ImageKnifeComponent onReadyNext is running!')