Thread replies: 10
Thread images: 3
2016-02-01 04:08:34 Post No. 46712
Post No. 46712
Need help getting a picture to flip in Java. How do I do it? Here's my code
* Horizontal flip method
* In this method, I've given you the basic structure of how things will look. There are a few incomplete assignments inside of the method. It is your job to figure out how to complete those assignments!
* This method works almost like the horizontal mirroring method you saw in your text book (pg 135), but instead of mirroring on the middle of the image, we want to flip it all the way.
* Hint: Why do we need tempColor in this case? I encourage you to reflect on this question if you find your method not working the way it should!**/
public void flipHorizontal()
//FILL THESE OUT AND THEN UNCOMMENT THEM!
int limit1 = this.getHeight();
int limit2 = this.getWidth();
Pixel leftPixel = null;
Pixel rightPixel = null;
for(int i = 0; i < limit1; i++)
for(int j = 0; j < limit2; j++)
leftPixel = getPixel(i,j);
rightPixel = getPixel(limit2 - 1 - i,j);
//FILL THIS OUT AND THEN UNCOMMENT IT!
//After you store away your pixel colors...call setColor() here on the appropriate pixels and flip the picture!
Shit's definitely not working.