harmony 鸿蒙ImageData
ImageData
NOTE
This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version.
The ImageData object is an object that stores pixel data rendered on a canvas.
Attributes
| Name | Type | Description | 
|---|---|---|
| width | number | Actual width of the rectangle on the canvas, in pixels. | 
| height | number | Actual height of the rectangle on the canvas, in pixels. | 
| data | <Uint8ClampedArray> | A one-dimensional array of color values. The values range from 0 to 255. | 
Example
<!-- xxx.hml -->
<div>
  <canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas>
</div>
// xxx.js
import promptAction from '@ohos.promptAction';
export default {
  onShow() {
    const el =this.$refs.canvas;
    const ctx = el.getContext('2d');
    ctx.fillRect(0,0,200,200)
    var imageData = ctx.createImageData(1,1)
    promptAction.showToast({
      message:imageData,
      duration:5000
    })
  }
}
你可能感兴趣的鸿蒙文章
harmony 鸿蒙JavaScript-compatible Web-like Development Paradigm
                        
                            0
                        
                        
                             赞
                        
                    
                    
                - 所属分类: 后端技术
 - 本文标签:
 
热门推荐
- 
                        2、 - 优质文章
 - 
                        3、 gate.io
 - 
                        7、 openharmony
 - 
                        9、 golang