diff --git a/entry/src/main/ets/pages/imageknifeTestCaseIndex.ets b/entry/src/main/ets/pages/imageknifeTestCaseIndex.ets index 0cdad89..762ff03 100644 --- a/entry/src/main/ets/pages/imageknifeTestCaseIndex.ets +++ b/entry/src/main/ets/pages/imageknifeTestCaseIndex.ets @@ -216,6 +216,14 @@ struct IndexFunctionDemo { }).margin({ top: 15 }) }.width('100%').height(60).backgroundColor(Color.Pink) + + Text("单帧gif测试").fontSize(15) + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button("单帧gif测试") + .onClick(() => { + router.pushUrl({ url: "pages/testSingleFrameGifPage" }); + }).margin({ top: 5, left: 3 }) + }.width('100%').height(60).backgroundColor(Color.Pink) } } .width('100%') diff --git a/entry/src/main/ets/pages/testSingleFrameGifPage.ets b/entry/src/main/ets/pages/testSingleFrameGifPage.ets new file mode 100644 index 0000000..16939eb --- /dev/null +++ b/entry/src/main/ets/pages/testSingleFrameGifPage.ets @@ -0,0 +1,51 @@ +import { ImageKnifeComponent } from '@ohos/imageknife/src/main/ets/components/imageknife/ImageKnifeComponent' +import { ImageKnifeOption } from '@ohos/imageknife/src/main/ets/components/imageknife/ImageKnifeOption' + +@Entry +@Component +struct TestSingleFrameGifPage { + @State message: string = '单帧gif测试' + @State options: ImageKnifeOption = { + loadSrc: $r('app.media.app_icon') + } + + build() { + Column() { + Column() { + Text(`${this.message}`) + .width("300vp") + .height("60vp") + .textAlign(TextAlign.Center) + .fontSize("50fp") + .fontWeight(FontWeight.Bold) + Button("加载单帧gif") + .margin(16) + .onClick(() => { + console.log("liyiwei 加载单帧gif") + this.options = { + loadSrc: $r('app.media.gifSample_single_frame'), + placeholderSrc:$r('app.media.icon_loading') + } + }) + Button("加载多帧gif") + .margin(16) + .onClick(() => { + console.log("liyiwei 加载多帧gif") + this.options = { + loadSrc: $r('app.media.gifSample'), + placeholderSrc:$r('app.media.icon_loading') + } + }) + ImageKnifeComponent({ imageKnifeOption: this.options }) + .margin(16) + .width(300) + .height(300) + } + .width("100%") + .height("100%") + .justifyContent(FlexAlign.Center) + } + .width("100%") + .height("100%") + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/gifSample_single_frame.gif b/entry/src/main/resources/base/media/gifSample_single_frame.gif new file mode 100644 index 0000000..c1b9f5c Binary files /dev/null and b/entry/src/main/resources/base/media/gifSample_single_frame.gif differ diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json index 8214dbd..63fea64 100644 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -27,6 +27,7 @@ "pages/dataShareUriLoadPage", "pages/manyPhotoShowPage", "pages/tempUrlTestPage", - "pages/drawFactoryTestPage" + "pages/drawFactoryTestPage", + "pages/testSingleFrameGifPage" ] }