How to change the color of a base64-encoded png image JQuery?

Ads
 

How to change the color of a base64-encoded png image JQuery?

I am going to change the colors of the pixels of a png image(which is in base64 format). This is my source code:

var myImg = new Image();
myImg.src = <...>; //"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAABQklEQVR4nO3bC27CMBAFQ";
myImg.onload = function() {
    var canvas = document.createElement("canvas");
    var ctx = canvas.getContext("2d");
    ctx.drawImage(myImg,0,0);
    var imgd = ctx.getImageData(0, 0, myImg.width, myImg.height);

    for (i = 0; i <imgd.data.length; i += 4) {
        imgd.data[i]   = 255;
        imgd.data[i+1] = 0;
        imgd.data[i+2] = 255;
    }
    ctx.putImageData(imgd, 0, 0);
    $("#Cell").append(myImg);
}

the problem is that when I check the value of imgd.data[i] (before changing the color), it is zero for every i. the original image is shown, but the color does not change. Do you know why?

View Answers

Ads









Related Tutorials/Questions & Answers:
How to change the color of a base64-encoded png image JQuery?
how to change color of titlebar in java
Advertisements
How can I change UIButton title color?
how to change div background color in javascript
How to change table row color when click on Hyper Link in jsp?
How to change color of opened Bootstrap drop down toggle?
how to re size image proportionately using java for different images like jpeg, png, gif.
how to create menubar and the below background color/image in java swing
How to change image size before adding to mysql using jsp
change color according to the database value
MKMapView Change Red Pin Color
dynamic image change javascript
Get image color
change navbar dropdown color in bootstrap
change color of back ground using switch
Get the color values as a matrix of color image
change the name of the image after uploading the image
How to change the face, change the face
How to change background, change background
How to design a changing color of the chameleon, changing color of the chameleon, color of the chameleon
Color Effect On Image
to change the styleclass color of <apex:outputlabel > onclick button function in javascript
How to design a color tray
PNG images become black colored during create image
Storing the Color Image pixel values into 2d array
How to Changing Toolbar Color using iPhone Application ?
which values we have to use for compressing any color image
Change JPanel background color from mouse entered/exit event
How to set the Gradient Color as a background color for Java Frame?
How to change functionlatiy in web page
How to remove the background color of bootstrap menu bar?

Ads