How to create a new ImageData object independently?

后端 未结 4 1131
灰色年华
灰色年华 2020-12-13 15:23

I want to create a new ImageData object in code. If I have a Uint8ClampedArray out of which I want to make an image object, what is the best way to do it?

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-13 16:27

    There is the createImageData() method. But for this you need the context of an existing canvas.

    var myImageData = context.createImageData(cssWidth, cssHeight);
    

    See here for more information.

提交回复
热议问题