Using the Javascript canvas element, is it possible to copy a 2-dimensional array of RGB values to a canvas?
<html>
<body>
<canvas id="canvas" height="200" width="200"></canvas>
<script type = "text/javascript">
//copy the following array to the canvas:
var arr1 = [
[[255, 255, 255],[200, 200, 0],[200, 200, 200]],
[[200, 0, 0],[200, 200, 0],[200, 200, 0]],
[[200, 200, 0],[200, 0, 0],[200, 200, 0]]
]
<script>
</body>
</html>
You can use
getImageData/putImageData. Just calculate the right index (it’s RGBA values in one big array): http://jsfiddle.net/zjypd/ (the jsFiddle has an enlarged canvas to show the pixels).