package filter.basic;

import filter.Filter;

import java.awt.image.BufferedImage;

/**
 * Created by Alexandre on 24/04/2016.
 */
public class VerticalFlip implements Filter
{
    @Override
    public BufferedImage perform(BufferedImage img)
    {
        BufferedImage res = new BufferedImage(img.getWidth(), img.getHeight(), img.getType());
        int w = img.getWidth();
        int h = img.getHeight();
        for (int i = 0; i < w; i++)
            for (int j = 0; j < h; j++)
                res.setRGB(i, j, img.getRGB(i, h - j - 1));
        return res;
    }

    @Override
    public String getName()
    {
        return "Vertical Flip";
    }
}
