Created
October 12, 2013 16:14
-
-
Save kishalmi/6951786 to your computer and use it in GitHub Desktop.
get ImageData from a WebGL renderer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var img = document.createElement('img'); | |
img.src = renderer.domElement.toDataURL('image/png'); | |
img.onload = function() { | |
var canvas = document.createElement('canvas'); | |
canvas.width = renderer.domElement.width; | |
canvas.height = renderer.domElement.height; | |
var ctx = canvas.getContext('2d'); | |
ctx.drawImage(img, 0, 0, img.naturalWidth, img.naturalHeight, 0, 0, canvas.width, canvas.height); | |
var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment