Question: I don't get vertical image at all. how do i write code for flipping image vertically in java? below is my vertical flip code: package

I don't get vertical image at all. how do i write code for flipping image vertically in java? below is my vertical flip code:

package pgrm8;

/**

* Filter that flips the image vertically.

* This class is COMPLETE. Don't change it. But model your other classes (such

* as FlipVerticalFilter) after it.

*/

public class flipVerticalFilter implements Filter

{

public void filter(PixelImage pi)

{

Pixel[][] data = pi.getData();

int width = pi.getWidth();

int mirrorPoint = width / 2;

Pixel leftPixel = null;

Pixel rightPixel = null;

{

for( int y = 0; y < pi.getHeight(); y++ )

{

for( int x = 0; x < mirrorPoint; x++ )

{

leftPixel = getPixel( x, y );

rightPixel = getPixel( width - 1 - x, y );

rightPixel.setColor( leftPixel.getColor() );

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!