diff --git a/entry/src/main/ets/pages/dpgTestCasePage.ets b/entry/src/main/ets/pages/dpgTestCasePage.ets new file mode 100644 index 0000000..1bbab89 --- /dev/null +++ b/entry/src/main/ets/pages/dpgTestCasePage.ets @@ -0,0 +1,80 @@ +/* + * 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/imageknife' +import {ImageKnifeOption} from '@ohos/imageknife' +import {RotateImageTransformation} from '@ohos/imageknife' +import {GrayscaleTransformation} from '@ohos/imageknife' +import {SketchFilterTransformation} from '@ohos/imageknife' + +@Entry +@Component +struct DpgTestCasePage { + @State imageKnifeOption1: ImageKnifeOption = + { + loadSrc: $r('app.media.jpgSample'), + size: { width: 300, height: 300 }, + placeholderSrc: $r('app.media.icon_loading'), + errorholderSrc: $r('app.media.icon_failed'), + margin:{left:5,top:5,right:5,bottom:5}, + + }; + + + build() { + Scroll() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Flex({direction:FlexDirection.Row}){ + Button("dpg网络资源") + .onClick(()=>{ + this.imageKnifeOption1 = { + loadSrc: "https://img13.360buyimg.com/n1/jfs/t1/220646/38/10395/30916/61d6e061E1a6d91c8/c0a9a67e726dd7a4.jpg.dpg", + size: { width: 300, height: 300 }, + placeholderSrc: $r('app.media.icon_loading'), + errorholderSrc: $r('app.media.icon_failed'), + margin:{left:5,top:5,right:5,bottom:5}, + }; + }).margin({left:5}).backgroundColor(Color.Blue) + Button("dpg本地资源") + .onClick(()=>{ + this.imageKnifeOption1 = { + loadSrc: $r('app.media.dpgSample'), + size: { width: 300, height: 300 }, + placeholderSrc: $r('app.media.icon_loading'), + errorholderSrc: $r('app.media.icon_failed'), + margin:{left:5,top:5,right:5,bottom:5}, + }; + }).margin({left:5}).backgroundColor(Color.Blue) + + } + .margin({top:15}) + + Text("下面为展示图片区域").margin({top:5}) + Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }){ + ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption1 }) + }.width(400).height(400).margin({top:10}).backgroundColor(Color.Pink) + + + } + } + .width('100%') + .height('100%') + } + + aboutToAppear() { + console.log("aboutToAppear()") + } +} + + diff --git a/entry/src/main/ets/pages/index.ets b/entry/src/main/ets/pages/index.ets index 13825ca..4414c5b 100644 --- a/entry/src/main/ets/pages/index.ets +++ b/entry/src/main/ets/pages/index.ets @@ -163,6 +163,15 @@ struct IndexFunctionDemo { }).margin({ top: 15 }) }.width('100%') .height(60).backgroundColor(Color.Pink) + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button("测试dpg图片格式加载") + .onClick(() => { + console.log("pages/dpgTestCasePage 页面跳转") + router.push({ uri: "pages/dpgTestCasePage" }); + }).margin({ top: 15 }) + + }.width('100%') + .height(60).backgroundColor(Color.Pink) } } .width('100%') diff --git a/entry/src/main/resources/base/media/dpgSample.dpg b/entry/src/main/resources/base/media/dpgSample.dpg new file mode 100644 index 0000000..6bf12a3 Binary files /dev/null and b/entry/src/main/resources/base/media/dpgSample.dpg differ diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json index 51c0ef6..fee6259 100644 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -28,6 +28,7 @@ "pages/testResourceManagerPage", "pages/testMultiThreadWorkerPage2", "pages/cropImagePage", - "pages/cropImagePage2" + "pages/cropImagePage2", + "pages/dpgTestCasePage" ] }