How to read binary data in IE9?

Viewed 14191

I'm working on some Javascript code that creates an alpha mask of a image using paths embedded by Photoshop. The onload handler of a IMG tag would call a clip(this). The function load the image's source file and scans through it. Here's the setup:

function clip(img) {
    var xhr = new XMLHttpRequest();
    xhr.open('GET', img.src, true);
    xhr.responseType = 'arraybuffer';
    xhr.target = img;

    xhr.onload = function(e) {
        var bytes = new Uint8Array(this.response);
        var p = findPhotoshopSegment(bytes);
        if(p) {
            var paths = parse8BIMData(bytes, p);

            /* ... replaces IMG with SVG tag ... */
        }
    };
    xhr.send();
}

You can see the code in action at http://flaczki.net46.net/JPEG/SVG.html

Currently, it only works in Firefox, Chrome, and Safari. It doesn't work in IE9. The browser supports SVG but not Uint8Array. Is there some kind of workaround?

2 Answers
Related