Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
wenyupan
wenyupan's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
error arrayindexoutofboundsexception
[1 Reply]
31-Oct-2010 01:43 PM
Forum:
Programming Questions
I tried to posterize a picture but when i clicked the mouse for the effect to happen. the error appears: arrayindexoutofboundsexception
the program is like this:
int i;
float total, r, g, b;
PImage img;
void setup(){
size(427,640);
background(255);
img=loadImage("Hey.jpg");
image(img, 0, 0);
}
void draw(){
}
void mouseClicked(){
img.loadPixels();
for(i=0; i<img.pixels.length; i++){
r=red(img.pixels[i]);
g=green(img.pixels[i]);
b=blue(img.pixels[i]);}
total=r+g+b;
if (total<182)
img.pixels[i]=color(0, 51, 76);
else if (total<364)
img.pixels[i]=color(217, 26, 33);
else if (total<546)
img.pixels[i]=color(112,150,158);
else
img.pixels[i]=color(252, 227, 166);
img.updatePixels();}
«Prev
Next »
Moderate user : wenyupan
Forum