HarmonyOS 现在是否支持图片的快速旋转绘制?

HarmonyOS
2024-12-23 15:08:13
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
superinsect

参考下这个demo:

import { image } from '@kit.ImageKit';
import { resourceManager } from '@kit.LocalizationKit';

@Entry
@Component
struct Index {
  @State angle: number = 0
  @State pixelMap?: image.PixelMap = undefined
  async aboutToAppear(): Promise<void> {
    let decodingOptions: image.DecodingOptions = {
      editable: true,
      desiredPixelFormat: 3,
    }
    const rawFileDescriptor: resourceManager.RawFileDescriptor = await getContext(this).resourceManager.getRawFd('startIcon.png');
    const imageSource: image.ImageSource = image.createImageSource(rawFileDescriptor);
    this.pixelMap = await imageSource.createPixelMap(decodingOptions)
  }

  build() {
    Column() {
      Image(this.pixelMap)
        .width(200)
        .height(200)
        .rotate({
          angle: this.angle,
        })
      Button("旋转+").onClick(async ()=>{
        this.angle += 10
      })
      Button("旋转-").onClick(async ()=>{
        this.angle -= 10
      })
    }
  }
}
  • 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.
分享
微博
QQ
微信
回复
2024-12-23 19:51:26
相关问题
现在是否支持Webp动图?
3123浏览 • 1回复 待解决
HarmonyOS现在是否有deepLink方案
1038浏览 • 1回复 待解决
HarmonyOS 是否支持绘制半圆
653浏览 • 1回复 待解决
HarmonyOS Image配置图片如何旋转
570浏览 • 1回复 待解决
HarmonyOS 图片旋转角度问题
530浏览 • 1回复 待解决
HarmonyOS 是否支持设置启动图片
617浏览 • 1回复 待解决
如何实现图片裁剪、旋转
1385浏览 • 1回复 待解决
HarmonyOS是否支持图片添加水印
978浏览 • 1回复 待解决
HarmonyOS 是否支持图片读取文字能力
736浏览 • 1回复 待解决