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
MKMapView Change Red Pin Color
change color according to the database value
How to change image size before adding to mysql using jsp
Change the color of the selected tab
Get image color
dynamic image change javascript
change navbar dropdown color in bootstrap
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
How to design a changing color of the chameleon, changing color of the chameleon, color of the chameleon
PNG images become black colored during create image
How to change the face, change the face
to change the styleclass color of <apex:outputlabel > onclick button function in javascript
How to change background, change background
Conversion from color to Gray Image - Java Beginners
Color Effect On Image
UINavigationBar Color - iPhone example
Storing the Color Image pixel values into 2d array
servlet backgorund color change - JSP-Servlet
Photoshop eye color brown to blue
UIWebView Background Color
which values we have to use for compressing any color image
Change JPanel background color from mouse entered/exit event
How to design a color tray

Ads