Noob needs brightness help
in
Programming Questions
•
1 year ago
Literally minutes new to processing and I have an error that i dont understand or know how to resolve, can someone help?
code:
PImage img;
void setup() {
size(200, 200);
frameRate(30);
img = loadImage("pip_boy_3000_wp.jpg");
img.loadPixels();
loadPixels();
}
void draw() { background(0);
image(img,0,0);
for (int x = 0; x < img.width; x++) {
for (int y = 0; y < img.height; y++ ) {
int loc = x + y*img.width;
float r,g,b;
r = red (img.pixels[loc]);
float maxdist = 50;
float d = dist(x,y,mouseX,mouseY);
float adjustbrightness = 255*(maxdist-d)/maxdist;
r += adjustbrightness;
r = constrain(r,0,255);
color c = color(r);
pixels[y*width + x] = c;
}
}
updatePixels();
}
error:
Aug 6 20:30:06 guy.local java[463] <Error>: CGContextGetCTM: invalid context 0x0
Aug 6 20:30:06 guy.local java[463] <Error>: CGContextSetBaseCTM: invalid context 0x0
Aug 6 20:30:06 guy.local java[463] <Error>: CGContextGetCTM: invalid context 0x0
Aug 6 20:30:06 guy.local java[463] <Error>: CGContextSetBaseCTM: invalid context 0x0
Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: 40000
at Img_bright.draw(Img_bright.java:42)
at processing.core.PApplet.handleDraw(PApplet.java:1631)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:680)
1