chinese直男口爆体育生外卖, 99久久er热在这里只有精品99, 又色又爽又黄18禁美女裸身无遮挡, gogogo高清免费观看日本电视,私密按摩师高清版在线,人妻视频毛茸茸,91论坛 兴趣闲谈,欧美 亚洲 精品 8区,国产精品久久久久精品免费

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

harmony-utils之SnapshotUtil,截圖相關工具類

童長老 ? 來源:jf_14594073 ? 作者:jf_14594073 ? 2025-07-03 11:36 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

harmony-utils之SnapshotUtil,截圖相關工具類

harmony-utils 簡介與說明


[harmony-utils] 一款功能豐富且極易上手的HarmonyOS工具庫,借助眾多實用工具類,致力于助力開發(fā)者迅速構建鴻蒙應用。其封裝的工具涵蓋了APP、設備、屏幕、授權、通知、線程間通信、彈框、吐司、生物認證、用戶首選項、拍照、相冊、掃碼、文件、日志,異常捕獲、字符、字符串、數(shù)字、集合、日期、隨機、base64、加密、解密、JSON等一系列的功能和操作,能夠滿足各種不同的開發(fā)需求。
[picker_utils] 是harmony-utils拆分出來的一個子庫,包含PickerUtil、PhotoHelper、ScanUtil。

下載安裝
ohpm i @pura/harmony-utils
ohpm i @pura/picker_utils

//全局初始化方法,在UIAbility的onCreate方法中初始化 AppUtil.init()
 onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
   AppUtil.init(this.context);
 }

API方法與使用


get 獲取已加載的組件的截圖,傳入組件的組件id,找到對應組件進行截圖
let pixelMap1 = await SnapshotUtil.get('snapshot_id1');
let pixelMap2 = SnapshotUtil.getSync('snapshot_id2');
createFromBuilder 在應用后臺渲染CustomBuilder自定義組件,并輸出其截圖
SnapshotUtil.createFromBuilder(() = > {
  this.RandomBuilder()
}).then((pixelMap) = > {
  Utils.showSheetImg(pixelMap);
}).catch((err: BusinessError) = > {
  ToastUtil.showToast("組件生成圖片異常!");
});

@Builder
RandomBuilder() {
  Column() {
    Text("Builder截圖")
      .fontSize(20)
      .fontWeight(FontWeight.Bold)
      .fontStyle(FontStyle.Italic)
      .margin({ top: 20 })
    Image($r("app.media.test_as4"))
      .margin({ top: 30, bottom: 10 })
      .padding(10)
      .width('95%')
      .backgroundColor(Color.Pink)
  }
  .backgroundColor(Color.Blue)
  .padding(10)
  .width('100%')
  .aspectRatio(1)
  .margin({ top: 50 })
  .id("rBuilder")
}
snapshot 獲取窗口截圖,使用Promise異步回調
let pixelMap3 = await SnapshotUtil.snapshot();
onSnapshotListener 開啟系統(tǒng)截屏事件的監(jiān)聽
SnapshotUtil.onSnapshotListener(() = > {
  ToastUtil.showToast("系統(tǒng)截圖了!");
  LogUtil.error("系統(tǒng)截圖了!");
});
removeSnapshotListener 關閉系統(tǒng)截屏事件的監(jiān)聽
SnapshotUtil.removeSnapshotListener();
 SnapshotUtil.removeSnapshotListener(snapshotCallBack);

創(chuàng)作不易,請給童長老點贊

審核編輯 黃宇

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權轉載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • Harmony
    +關注

    關注

    0

    文章

    108

    瀏覽量

    3410
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評論

    相關推薦
    熱點推薦

    harmony-utilsCacheUtil,緩存工具

    harmony-utilsCacheUtil,緩存工具
    的頭像 發(fā)表于 07-04 16:36 ?252次閱讀

    harmony-utilsCharUtil,字符工具

    harmony-utilsCharUtil,字符工具
    的頭像 發(fā)表于 07-04 16:34 ?263次閱讀

    harmony-utilsCrashUtil,異常相關工具

    harmony-utilsCrashUtil,異常相關工具
    的頭像 發(fā)表于 07-04 16:33 ?242次閱讀

    harmony-utilsDeviceUtil,設備相關工具

    harmony-utilsDeviceUtil,設備相關工具
    的頭像 發(fā)表于 07-03 18:27 ?320次閱讀

    harmony-utilsDisplayUtil,屏幕相關工具

    harmony-utilsDisplayUtil,屏幕相關工具
    的頭像 發(fā)表于 07-03 18:26 ?253次閱讀

    harmony-utilsEmitterUtil,Emitter工具

    harmony-utilsEmitterUtil,Emitter工具
    的頭像 發(fā)表于 07-03 18:24 ?250次閱讀

    harmony-utilsFileUtil,文件相關工具

    harmony-utilsFileUtil,文件相關工具
    的頭像 發(fā)表于 07-03 18:23 ?295次閱讀

    harmony-utilsFormatUtil,格式化工具

    harmony-utilsFormatUtil,格式化工具
    的頭像 發(fā)表于 07-03 18:22 ?309次閱讀

    harmony-utilsImageUtil,圖片相關工具

    harmony-utilsImageUtil,圖片相關工具
    的頭像 發(fā)表于 07-03 18:22 ?453次閱讀

    harmony-utilsLocationUtil,定位相關工具

    harmony-utilsLocationUtil,定位相關工具 harmony-utils
    的頭像 發(fā)表于 07-03 18:13 ?292次閱讀

    harmony-utilsPreviewUtil,文件預覽工具

    harmony-utilsPreviewUtil,文件預覽工具 harmony-utils 簡介與說明 [
    的頭像 發(fā)表于 07-03 11:40 ?276次閱讀

    harmony-utilsWindowUtil,窗口相關工具

    harmony-utilsWindowUtil,窗口相關工具 harmony-utils
    的頭像 發(fā)表于 06-30 17:33 ?256次閱讀

    harmony-utilsAuthUtil,生物認證相關工具

    # harmony-utilsAuthUtil,生物認證相關工具 ## harmony-utils
    的頭像 發(fā)表于 06-26 17:43 ?251次閱讀

    harmony-utilsNetworkUtil,網(wǎng)絡相關工具

    harmony-utilsNetworkUtil,網(wǎng)絡相關工具 harmony-utils
    的頭像 發(fā)表于 06-25 23:46 ?145次閱讀

    harmony-utilsDateUtil,日期工具

    harmony-utilsDateUtil,日期工具
    的頭像 發(fā)表于 06-25 22:15 ?204次閱讀