package plugin.basic;

import java.awt.*;
import java.awt.Color;
import java.awt.image.BufferedImage;

import plugin.IPlugin;

public class InvertFilter implements IPlugin {

    @Override
    public BufferedImage perform(BufferedImage img) {
        BufferedImage res = new BufferedImage(img.getWidth(), img.getHeight(), img.getType());

        for (int i = 0; i < img.getWidth(); i++)
            for (int j = 0; j < img.getHeight(); j++) {
                Color c = new Color(img.getRGB(i, j));
                c = new Color(255 - c.getRed(), 255 - c.getGreen(), 255 - c.getBlue());
                res.setRGB(i, j, c.getRGB());
            }
        return res;
    }

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

}