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
      })
    }
  }
}
分享
微博
QQ
微信
回复
2024-12-23 19:51:26
相关问题
现在是否支持Webp动图?
2675浏览 • 1回复 待解决
HarmonyOS现在是否有deepLink方案
754浏览 • 1回复 待解决
HarmonyOS 是否支持绘制半圆
271浏览 • 1回复 待解决
HarmonyOS Image配置图片如何旋转
237浏览 • 1回复 待解决
HarmonyOS 是否支持设置启动图片
296浏览 • 1回复 待解决
HarmonyOS 图片旋转角度问题
274浏览 • 1回复 待解决
如何实现图片裁剪、旋转
939浏览 • 1回复 待解决
HarmonyOS是否支持图片添加水印
597浏览 • 1回复 待解决
HarmonyOS 是否支持图片读取文字能力
336浏览 • 1回复 待解决