Hey, everyone. I got a problem that Processing break down when I execute the following pieces of code:
- PImage img;
- void setup () {
- size(60, 60);
- img = loadImage("aaa.png");
- }
- void draw () {
- int count = 0;
- loadPixels();
- // Since we are going to access the image's pixels too;
- img.loadPixels();
- for (int y = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
- int loc = x + y * width;
- ////////////////////////////////////////////////////////////////
- count++;
- println(count);
- ////////////////////////////////////////////////////////////////
- // Image Processing Algorithm would go here
- float r = red (img.pixels[loc]);
- float g = green(img.pixels[loc]);
- float b = blue (img.pixels[loc]);
- // Image Processing would go here
- // Set the display pixel to the image pixel
- pixels[loc] = color(r, g, b);
- }
- }
- updatePixels();
- }
1