开发者

What does this code do for the picture class

开发者 https://www.devze.com 2023-02-16 00:52 出处:网络
public void modifyPicture() { Pixel pixel=null; Pixel[ ] pixels=this.getPixels(); for(int x=0; x&l开发者_开发百科t;this.getPixels().length/2; x++ )
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.

0

精彩评论

暂无评论...
验证码 换一张
取 消