Change Contents of the Bubble
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Midterm exam 1 review Sp2005: Flip the other way

Comments? Questions? Answers? Questions on Answers? Comments on Answers?




//Method to flip an image right to left
public Picture flip() {
Pixel currPixel;
Picture target = new Picture(this.getWidth(),this.getHeight());
for (int srcx = getWidth()-1, trgx = 0; srcx > 0; srcx–, trgx++)
{
for (int srcy = 0, trgy = 0; srcy getHeight(); srcy++, trgy++)
{
// get the current pixel
currPixel = this.getPixel(srcx,srcy);
// copy the color of currPixel into target
target.getPixel(trgx,trgy).setColor(currPixel.getColor());
}
};
return target;
}

Student36

Type a less than sign with &lt;, like this <




for (int srcy = 0, trgy = 0; srcy getHeight(); srcy++, trgy++)
// You need a less than sign!!!-yt

Link to this Page