Noob question - Alpha not working
in
Programming Questions
•
2 years ago
Hello everyone.
I'm trying to convert all red pixels in my PImage "a" into transparent pixels, but it's not working.
size (500,500);
background(255,0,255);
PImage a =loadImage ("1.png");
for (int i = 0; i<a.width; i++) for (int j = 0; j<a.height; j++){
if (a.pixels[i+a.width*j]==color(255,0,0)) a.pixels[i+a.width*j]=color(255,255,255,0);
}
image(a,0,0);
The program is recognizing correctly which pixels I want replaced, but instead of making them transparent, it's making them opaque white.
I hope the solution is not too difficult...
Thanks =)
I'm trying to convert all red pixels in my PImage "a" into transparent pixels, but it's not working.
size (500,500);
background(255,0,255);
PImage a =loadImage ("1.png");
for (int i = 0; i<a.width; i++) for (int j = 0; j<a.height; j++){
if (a.pixels[i+a.width*j]==color(255,0,0)) a.pixels[i+a.width*j]=color(255,255,255,0);
}
image(a,0,0);
The program is recognizing correctly which pixels I want replaced, but instead of making them transparent, it's making them opaque white.
I hope the solution is not too difficult...
Thanks =)
1