I tried a lot of methods i saw, but none of them seem to work.
I am trying to take an image, save it and when I paste it into my canvas turn the white pixels into transparent.
here is some code that I have written so far(based on another forum post):
int q;
int c;
int x;
int y;
int i;
PImage save;
PImage newImg;
void setup() {
fullScreen();
background(255);
color c = get(25, 25);
fill©;
noStroke();
save = loadImage(“partialSave.png”);
}
void draw() {
fill(0);
rect(0, q, width, 50);
q = q + 50;
if ( c >= 255) {
c = 0;
} else {
c = c + 30;
}
fill(255);
rect(0, 0, 50, height);
rect(0, 0, width, 50);
rect(width-50, 0, 50, height);
rect(0, height-50, width, 50);
}
void mousePressed() {
save(“partialSave.png”);
}
void keyPressed() {
if (keyPressed && key == ‘s’) {
image(save, mouseX, mouseY, 100, 100);
loadPixels();
for (int i = 0; i < width*height; i++) {
if (pixels[i] == 0x000000) { // If it is red
pixels[i] = 0xff00ff00; // Make it green
}
}
updatePixels();
}
reset();
}
void reset() {
save = loadImage(“partialSave.png”);
}
I hope someone has some tips to help me on my way.