Creating texture from getImageData (Javascript)

后端 未结 3 1688
谎友^
谎友^ 2021-01-23 16:18

It is possibile to create a texture (to use on a element in a canvas) from the getImageData array of another canvas (in the same html page)? maybe without three.js? Thanks a lot

3条回答
  •  迷失自我
    2021-01-23 16:57

    Thats the point of getImageData, getting an image to manipulate it and then draw on any canvas.

    imageData = someContext.getImageData(0, 0, canvasWidth, canvasHeight);
    anotherContext.putImageData(imageData, 0, 0);
    

    doing things like: http://jsfiddle.net/jaibuu/myRGr/

    If you don't intend to do pixel manipulation, you should only use drawImage(), without getImageData/putImageData which are slower though.

提交回复
热议问题