Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions