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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started