copy() color problem
in
Core Library Questions
•
3 months ago
Hello, I've noticed what seems to be a bug using copy on any surface or PImage. It seems that when using copy() I'll always loose one R, G and B value.
In other words, 255 will be 254 in the copy, 254 will become 253 and so on.
Here's a sketch to illustrate the behaviour:
- void setup() {
- size(300, 300, P2D);
- background(0);
- //setup the color white
- color white = color(255,255,255);
- //draw an ellipse with that white color
- noStroke();
- fill(white);
- ellipse(150,150,50,50);
- //sample the white color drawn
- color white_sample_1 = get(150,150);
- println("White sample #1 = " + red(white_sample_1)); //outputs: 255.0
- //now copy the entire image to the same area again
- copy(0,0,300,300,0,0,300,300);
- //sample the white color
- color white_sample_2 = get(150,150);
- println("White sample #2 = " + red(white_sample_2)); //outputs: 254.0
- //now copy the entire image to the same area again
- copy(0,0,300,300,0,0,300,300);
- //sample the white color
- color white_sample_3 = get(150,150);
- println("White sample #3 = " + red(white_sample_3)); //outputs: 253.0
- }
This is causing me a lot of headache and problem using processing to process changes in images and sampling by colors exactly. Is this somehow logical and intended, please give me a quick run-down on why that is!
I'm using Processing 2.0
Thanks for any help on this!
1