HarmonyOS 目前如何截超长图

HarmonyOS
2024-12-24 16:24:00
621浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Heiang

示例参考:

import componentSnapshot from '@ohos.arkui.componentSnapshot'
import image from '@ohos.multimedia.image'

@Entry
@Component
struct SnapshotTestPage {
  @State pixmap: image.PixelMap | undefined = undefined
  build() {
    Column() {
      Scroll() {
        Column() {
          Image($r('app.media.1111111')).width('100%').height('auto').id('image1')
          Image($r('app.media.1111111')).width('100%').height('auto').id('image2')
          Image($r('app.media.1111111')).width('100%').height('auto').id('image3')
          Image($r('app.media.1111111')).width('100%').height('auto').id('image4')
        }.width('100%').id('column')
      }.width('100%')
      .height('100%')
      .id('scroll')
      .onAreaChange((oldValue: Area, newValue: Area) => {
        console.info('组件宽高:' + vp2px(newValue.width as number).toString() + ',' +
        vp2px(newValue.height as number).toString())
      })

      Button("click to generate UI snapshot")
        .onClick(() => {

          componentSnapshot.get("scroll", (error: Error, pixmap: image.PixelMap) => {
            if (error) {
              console.log("error: " + JSON.stringify(error))
              return;
            }
            this.pixmap = pixmap
            this.pixmap.getImageInfo().then((imageInfo: image.ImageInfo) => {
              if (imageInfo == undefined) {
                console.error("Failed to obtain the image pixel map information.");
              }
              console.info('imageSize: ' + imageInfo.size.width.toString() + ',' + imageInfo.size.height.toString())
            })
          })
        }).margin(10)
        .position({ top: 100, left: 20 })
    }
    .width('100%')
    .height('100%')
    .alignItems(HorizontalAlign.Center)
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
分享
微博
QQ
微信
回复
2024-12-24 18:24:47
相关问题
HarmonyOS如何获取屏图片
1183浏览 • 1回复 待解决
HarmonyOS 超长JSON字符串解析
1258浏览 • 2回复 待解决
HarmonyOS 如何监听屏幕屏事件
871浏览 • 1回复 待解决
HarmonyOS如何实现当前禁止屏?
746浏览 • 0回复 待解决
HarmonyOS 如何禁用屏、录屏
1023浏览 • 1回复 待解决
HarmonyOS屏功能如何实现
892浏览 • 1回复 待解决
HarmonyOS 如何设置页面防止屏?
965浏览 • 1回复 待解决
HarmonyOS如何实现当前禁止
1574浏览 • 1回复 待解决
HarmonyOS 如何监听屏事件触发
1006浏览 • 1回复 待解决
HarmonyOS Text.textOverflow超长时显示异常
1091浏览 • 1回复 待解决
HarmonyOS
954浏览 • 1回复 待解决
HarmonyOS 如何支持.9
617浏览 • 1回复 待解决
HarmonyOS 单行超长文本换行不生效
630浏览 • 1回复 待解决
HarmonyOS 首选项超长string存储失败
771浏览 • 1回复 待解决
HarmonyOS 如何禁止屏和录屏?
1467浏览 • 1回复 待解决
HarmonyOS 如何设置放屏录屏?
1266浏览 • 1回复 待解决
HarmonyOS 如何屏防录屏
1043浏览 • 1回复 待解决
HarmonyOS 如何加载svga
584浏览 • 1回复 待解决
HarmonyOS如何显示饼状
587浏览 • 0回复 待解决