-
-
Save liligot/8887265c6252b86558aca3c975721bf0 to your computer and use it in GitHub Desktop.
draw image using DataURI
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
socket.on("render_data", function(data) { | |
console.log("render_data"); | |
var canvas = document.getElementById('mycanvas'); | |
var ctx = canvas.getContext('2d'); | |
var canvasWidth = canvas.width; | |
var canvasHeight = canvas.height; | |
var img = new Image(); | |
img.onload = function() { ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight); }; | |
img.src = data; // Assume data is provided as DataURI format | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment