0

Here is my JS code :

 UTIF._imgLoaded = function(e)
            {
                var page = UTIF.decode(e.target.response)[0], rgba = UTIF.toRGBA8(page), w=page.width, h=page.height;


                var string = rgba.join();
                console.log("rgba : ", rgba);

                var ind = UTIF._xhrs.indexOf(e.target), img = UTIF._imgs[ind];
                UTIF._xhrs.splice(ind,1);  UTIF._imgs.splice(ind,1);
                var cnv = document.createElement("canvas");  cnv.width=w;  cnv.height=h;
                var ctx = cnv.getContext("2d"), imgd = ctx.createImageData(w,h);
                for(var i=0; i<rgba.length; i++) imgd.data[i]=rgba[i];       ctx.putImageData(imgd,0,0);
                var attr = ["style","class","id"];
                for(var i=0; i<attr.length; i++) cnv.setAttribute(attr[i], img.getAttribute(attr[i]));
                img.parentNode.replaceChild(cnv,img);

                document.getElementById("myText").innerHTML = string;
            }

I get a Uint8Array() RGBA of image, here is console.log of this : enter image description here

Here is image with rgba array as a string in HTML:

enter image description here

Is that possible to manipulate this array, to ex. change colors? Thanks for help!

bafix2203
  • 541
  • 7
  • 25
  • Is your goal to change the image visually? Or do you want to able modify the array so that the image updates according to your change? Those two are different things but one is a lot easier to achieve I think. – maxpaj Dec 10 '17 at 09:50
  • @maxpaj i want to able modify the array so that the image updates according to my change. Have you any idea how to do it? – bafix2203 Dec 10 '17 at 12:13
  • Maybe this will help: https://stackoverflow.com/questions/7117495/how-to-create-an-image-from-array-of-pixel-colors-javascript – maxpaj Dec 10 '17 at 12:33
  • Possible duplicate of [Manipulate RGBA Javascript](https://stackoverflow.com/questions/47737257/manipulate-rgba-javascript) – JJJ Dec 10 '17 at 12:50

0 Answers0