colormode in relation with Thread
in
Programming Questions
•
1 year ago
I have a Thread running and it calls to a method getColor.
When i use it my processing starts to flicker and colors changes sometimes. Of things that have nothing to do with it (like the background).
Anyone a idea why?
- private int getColor(PImage img) {
- int r = 0;
- int g = 0;
- int b = 0;
- int a = 0;
- int c;
- for (int i = 0; i < img.pixels.length; i++) {
- c = img.pixels[i];
- r += (c >> 16) & 0xFF;
- g += (c >> 8) & 0xFF;
- b += c & 0xFF;
- a += (c >> 24) & 0xFF;
- }
- r = r / img.pixels.length;
- g = g / img.pixels.length;
- b = b / img.pixels.length;
- a = a / img.pixels.length;
- c = p.color(r, g, b, a);
- return c;
- }
1