Created
December 29, 2013 16:38
-
-
Save seansullivan/8172122 to your computer and use it in GitHub Desktop.
Load image into canvas
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
<canvas id="canvas"></canvas> | |
<script type="text/javascript"> | |
var can = document.getElementById('canvas'); | |
var ctx = can.getContext('2d'); | |
var img = new Image(); | |
img.onload = function(){ | |
can.width = img.width; | |
can.height = img.height; | |
ctx.drawImage(img, 0, 0, img.width, img.height); | |
} | |
img.src = 'test.jpg'; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment