Merge remote-tracking branch 'origin/master'

# Conflicts:
#	entry/src/main/resources/base/media/iconsvg.svg
This commit is contained in:
liuhaikang 2023-09-07 11:41:14 +08:00
commit c5f658f346
1 changed files with 33 additions and 3 deletions

View File

@ -18,7 +18,8 @@ import {SVGParseImpl} from '@ohos/imageknife'
@Component @Component
struct svgTestCasePage { struct svgTestCasePage {
@State pixels:PixelMap = undefined @State svgSamplePixelMap:PixelMap = undefined
@State svgIconPixelMap:PixelMap = undefined
build() { build() {
Scroll() { Scroll() {
@ -32,7 +33,7 @@ struct svgTestCasePage {
console.log('basicTestFileIOPage - 本地加载资源 解析后数据data = ' + data) console.log('basicTestFileIOPage - 本地加载资源 解析后数据data = ' + data)
let svgImpl = new SVGParseImpl(); let svgImpl = new SVGParseImpl();
svgImpl.parseSvg(data.buffer).then((pixelmap)=>{ svgImpl.parseSvg(data.buffer).then((pixelmap)=>{
this.pixels = pixelmap; this.svgSamplePixelMap = pixelmap;
}) })
}) })
.catch(err => { .catch(err => {
@ -46,7 +47,36 @@ struct svgTestCasePage {
Text("下面为展示图片区域").margin({top:5}) Text("下面为展示图片区域").margin({top:5})
Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }){ Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }){
Image(this.pixels) Image(this.svgSamplePixelMap)
.width(400)
.height(400)
.backgroundColor(Color.Pink)
}.width(400).height(400).margin({top:10}).backgroundColor(Color.Pink)
Flex({direction:FlexDirection.Row}){
Button("加载SVG图片")
.onClick(()=>{
globalThis.ImageKnife.getImageKnifeContext().resourceManager.getMedia($r('app.media.iconsvg').id)
.then(data => {
console.log('basicTestFileIOPage - 本地加载资源 解析后数据data = ' + data)
let svgImpl = new SVGParseImpl();
svgImpl.parseSvg(data.buffer).then((pixelmap)=>{
this.svgIconPixelMap = pixelmap;
})
})
.catch(err => {
console.log('basicTestFileIOPage - 本地加载资源err' + JSON.stringify(err));
})
}).margin({left:5}).backgroundColor(Color.Blue)
}
.margin({top:15})
Text("下面为展示图片区域").margin({top:5})
Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }){
Image(this.svgIconPixelMap)
.width(400) .width(400)
.height(400) .height(400)
.backgroundColor(Color.Pink) .backgroundColor(Color.Pink)