How to create CCImage from bufferarray?

How to create CCImage from bufferarray?
0.0 0


I am trying download image from server.
The code below can show image on the web side:

  var xhr = new XMLHttpRequest();
  'GET', pic_url, true);
            xhr.responseType = 'arraybuffer';
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    var restype = xhr.responseType;

                    if( xhr.response instanceof  ArrayBuffer){
                        cc.log("type is ArrayBuffer");
                        cc.log("type is not ArrayBuffer");

                var blob = new Blob([xhr.response], {type: "image/png"});
                cc.log("blob.size: "+blob.size);
                var img = document.createElement('img');
                    img.onload = function(e) {

                        window.URL.revokeObjectURL(img.src); // Clean up after yourself.
                        cc.log("image onload");
                    img.src = window.URL.createObjectURL(blob);

But today I want to save xhr.response to CCImage,
how can I do?



you’d better ask this at