public void modifyPicture()
{
Pixel pixel=null;
Pixel[ ] pixels=this.getPixels();
for(int x=0; x&l开发者_开发百科t;this.getPixels().length/2; x++ )
{
pixel= pixels [x];
int r =pixel.getRed()/2
int g=pixel.getGreen()/2;
int b=pixel.getBlue()/2;
pixel.setColor(new Color(r,g,b) ) )
}
}
Looks like it's iterating over every pixel in the image and dividing the value of each color channel by 2. The end result seems to be that it would darken the image hald the distance to black.
Every second pixel is divided by 2. This could be used f.e. to darken the whole pic.
精彩评论