| Listing 7. The method named mirrorHoriz. |
|---|
private Picture mirrorHoriz(Picture pix){
Pixel topPixel = null;
Pixel bottomPixel = null;
int midpoint = pix.getHeight()/2;
int height = pix.getHeight();
for(int col = 0;
< pix.getWidth();
col++){
for(int row = 0;
row < midpoint;
row++){
topPixel = pix.getPixel(col,row);
bottomPixel =
pix.getPixel(col,height-1-row);
bottomPixel.setColor(
topPixel.getColor());
}//end inner loop
}//end outer loop
return pix;
}//end mirrorHoriz
//-----------------------------------//
}//end class Prob01Runner
|