canvas增加图片抗锯齿-代码格式修改
Signed-off-by: zourenjie <zourenjie1@h-partners.com>
This commit is contained in:
parent
08ae90f7e4
commit
607156887a
|
@ -286,11 +286,11 @@ 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)
|
Text('测试图片抗锯齿').fontSize(15)
|
||||||
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||||
Button("测试图片抗锯齿")
|
Button('测试图片抗锯齿')
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
router.pushUrl({ url: "pages/testImageAntiAliasingWithPage" });
|
router.pushUrl({ url: 'pages/testImageAntiAliasingWithPage' });
|
||||||
}).margin({ top: 5, left: 3 })
|
}).margin({ top: 5, left: 3 })
|
||||||
}.width('100%').height(60).backgroundColor(Color.Pink)
|
}.width('100%').height(60).backgroundColor(Color.Pink)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,10 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import {ImageKnifeComponent} from '@ohos/libraryimageknife'
|
import { ImageKnifeComponent } from '@ohos/libraryimageknife'
|
||||||
import {ImageKnifeOption} from '@ohos/libraryimageknife'
|
import { ImageKnifeOption } from '@ohos/libraryimageknife'
|
||||||
import {RotateImageTransformation} from '@ohos/libraryimageknife'
|
import { RotateImageTransformation } from '@ohos/libraryimageknife'
|
||||||
import {RoundedCornersTransformation} from '@ohos/libraryimageknife'
|
import { RoundedCornersTransformation } from '@ohos/libraryimageknife'
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
|
@ -23,28 +23,24 @@ struct TestImageAntiAliasingWithPage {
|
||||||
@State imageKnifeOption1: ImageKnifeOption =
|
@State imageKnifeOption1: ImageKnifeOption =
|
||||||
{
|
{
|
||||||
loadSrc: "https://thirdwx.qlogo.cn/mmopen/xxxxx",
|
loadSrc: "https://thirdwx.qlogo.cn/mmopen/xxxxx",
|
||||||
|
|
||||||
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 imageKnifeOption: ImageKnifeOption =
|
@State imageKnifeOption: ImageKnifeOption =
|
||||||
{
|
{
|
||||||
loadSrc: "https://hbimg.huabanimg.com/xxxxx",
|
loadSrc: "https://hbimg.huabanimg.com/xxxxx",
|
||||||
|
|
||||||
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 imageKnifeOption3: ImageKnifeOption =
|
@State imageKnifeOption3: ImageKnifeOption =
|
||||||
{
|
{
|
||||||
loadSrc: "https://hbimg.huabanimg.com/xxxxx",
|
loadSrc: "https://hbimg.huabanimg.com/xxxxx",
|
||||||
|
|
||||||
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 imageKnifeOption4: ImageKnifeOption =
|
@State imageKnifeOption4: ImageKnifeOption =
|
||||||
{
|
{
|
||||||
loadSrc: "https://hbimg.huabanimg.com/xxxxx",
|
loadSrc: "https://hbimg.huabanimg.com/xxxxx",
|
||||||
|
|
||||||
placeholderSrc: $r('app.media.icon_loading'),
|
placeholderSrc: $r('app.media.icon_loading'),
|
||||||
errorholderSrc: $r('app.media.icon_failed'),
|
errorholderSrc: $r('app.media.icon_failed'),
|
||||||
};
|
};
|
||||||
|
@ -54,7 +50,9 @@ struct TestImageAntiAliasingWithPage {
|
||||||
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||||
ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption1 }).width(600).height(600)
|
ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption1 }).width(600).height(600)
|
||||||
Image($r('app.media.icon_failed'))
|
Image($r('app.media.icon_failed'))
|
||||||
.width(600).height(600).margin(15)
|
.width(600)
|
||||||
|
.height(600)
|
||||||
|
.margin(15)
|
||||||
.overlay('png', { align: Alignment.Bottom, offset: { x: 0, y: 20 } })
|
.overlay('png', { align: Alignment.Bottom, offset: { x: 0, y: 20 } })
|
||||||
.interpolation(ImageInterpolation.High)
|
.interpolation(ImageInterpolation.High)
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,10 +115,9 @@ export struct ImageKnifeComponent {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.onReady(() => {
|
.onReady(() => {
|
||||||
let ctx = this.context
|
let ctx = this.context;
|
||||||
ctx.imageSmoothingEnabled = true
|
ctx.imageSmoothingEnabled = true;
|
||||||
ctx.imageSmoothingQuality = 'high'
|
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!')
|
||||||
|
|
Loading…
Reference in New Issue