Listing 4. The method named mirrorUpperQuads.
private Picture mirrorUpperQuads(Picture pix){
Pixel leftPixel = null;
Pixel rightPixel = null;
int midpoint = pix.getWidth()/2;
int width = pix.getWidth();
for(int row = 0;row < pix.getHeight()/2;
row++){
for(int col = 0;col < midpoint;col++){
leftPixel = pix.getPixel(col,row);
rightPixel =
pix.getPixel(width-1-col,row);
rightPixel.setColor(
leftPixel.getColor());
}//end inner loop
}//end outer loop
return pix;
}//end mirrorUpperQuads
|