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

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









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
color change
How can I change UIButton title color?
how to change div background color in javascript
how to change background color in dojo tab container - Framework
how to re size image proportionately using java for different images like jpeg, png, gif.
how do you change the message box to a specific color
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 create menubar and the below background color/image in java swing
How to change backgroundcolor and foreground color of JLabel in Java - Java Beginners
change player dress color
change color according to the database value
MKMapView Change Red Pin Color
Change the color of the selected tab
dynamic image change javascript
Get image color
change navbar dropdown color in bootstrap
How to change image size before adding to mysql using jsp
JavaScript change background color automatically
To change the color of text hyperlinks midway
To change the color of text hyperlinks midway
To change the color of text hyperlinks midway
Convert Black & White Image to Color Image
change color of back ground using switch
change one type of color in between more colors
Java Servlet Change Background Color
Change Color and Font of text
Get the color values as a matrix of color image
Change background color of text box - Java Beginners
PHP GD Colorization of image
Photoshop change a background image
PHP GD image negative Color
change the name of the image after uploading the image
PNG images become black colored during create image
to change the styleclass color of <apex:outputlabel > onclick button function in javascript
Conversion from color to Gray Image - Java Beginners
How to design a changing color of the chameleon, changing color of the chameleon, color of the chameleon
Color Effect On Image
UINavigationBar Color - iPhone example
Storing the Color Image pixel values into 2d array
How to change the face, change the face
How to change background, change background
servlet backgorund color change - JSP-Servlet
Photoshop eye color brown to blue
UIWebView Background Color
Change JPanel background color from mouse entered/exit event
which values we have to use for compressing any color image
changing Chunk Color

Ads