How to convert a javascript array to Uint8ClampedArray which works in IE
<p>I have array of pixels which obtain from a  raw image in a smart card (you could see <a href="https://stackoverflow.com/questions/34963963/converting-a-hex-string-of-a-raw-image-to-a-bitmap-image-in-javascript">my open problem</a>) and I want to draw it in a canvas:</p>

<pre><code>&lt;html&gt;
    &lt;head&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;canvas width="320" height="480"&gt;&lt;/canvas&gt;
    &lt;/body&gt;
    &lt;script&gt;
        var canvas = document.querySelector('canvas'),
            ctx = canvas.getContext('2d'),
            width = canvas.width,
            height = canvas.height,
            pxlength = width * height;
            //suppose data is an array of pixels with the length of pxlength 
        imageData = new ImageData(data, width, height);
        ctx.putImageData(imageData,0,0);
    &lt;/script&gt;"
&lt;/html&gt;
</code></pre>

<p>However as data is not a Uint8ClampedArray, it take this error: Fail to construct 'ImageData': parameter1 is not of type 'Uint8ClamedArray'.</p>

<p>Also, I want to use this code in IE9 and upper. I think IE does not support Uint8ClamedArray.</p>