OLD | NEW |
(Empty) | |
| 1 function printSizes(imageId, outputId) { |
| 2 var image = document.getElementById(imageId); |
| 3 image.addEventListener('load', function() { |
| 4 var output = document.getElementById(outputId); |
| 5 output.innerHTML = 'image stats: ' |
| 6 + 'size(' + image.width + ',' + image.height + '), ' |
| 7 + 'naturalSize(' + image.naturalWidth + ',' + image.naturalHeight + ')<b
r/>' |
| 8 + 'image codes: ' |
| 9 + image.outerHTML.replace(/</g, "<").replace(/>/g, ">"); |
| 10 }); |
| 11 } |
| 12 |
| 13 function drawCanvas(imageId, canvasId, canvasWidth, canvasHeight) { |
| 14 var image = document.getElementById(imageId); |
| 15 var canvas = document.getElementById(canvasId); |
| 16 canvas.width = canvasWidth; |
| 17 canvas.height = canvasHeight; |
| 18 var context = canvas.getContext('2d'); |
| 19 context.drawImage(image, 0, 0); |
| 20 } |
OLD | NEW |