loadPixels or get() does not return valid colors on transparent images
in
Programming Questions
•
1 month ago
Using 2.0.3 and loadPixels and get() just goes nuts on a background image with transparency. It seems to only pick up white/black/transparent no other colors.
- PImage myImage;
- color c;
- void setup(){
- size(1200, 760);
- myImage = loadImage("background1.png");
- image(myImage, 0, 0, myImage.width, myImage.height);
- }
- void draw(){
- loadPixels();
- c = pixels[mouseX + mouseY * myImage.width];
- fill(c);
- noStroke();
- rect(500, 350, 50, 50);
- println(c);
- }
background1.png is a image that has certain areas transparent. When filling the rect with mouse color it does not work. If I remove transparency entirely it works fine. Can anyone explain how to get pixel color off images that are transparent?
1