package projet2;
import java.awt.image.BufferedImage;
public interface Filtre {
BufferedImage filtrage(BufferedImage src);
}
_______
package projet2;
import java.awt.Color;
import java.awt.image.BufferedImage;
public class FiltreNB implements Filtre {
public BufferedImage filtrage(BufferedImage src) {
BufferedImage dst = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_INT_RGB);
for(int y=0; y<dst.getHeight(); y++)
{
for(int x=0; x<dst.getWidth(); x++)
{
Color color = new Color(src.getRGB(x,y));
int red = color.getRed();
int green = color.getGreen();
int blue = color.getBlue();
int moy = (int)((red+green+blue)/3);
color = new Color(moy, moy , moy);
dst.setRGB(x, y, color.getRGB());
}
}
return dst;
__________________________
package projet2;
import projet2.Filtre;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class ClasseMain {
public static void main(String[] args) throws IOException {
BufferedImage src = ImageIO.read(new File(args[0]));
filtrage(src);
ImageIO.write(filtrage(src), args[3], new File(args[2]));
}
}
___
Je n'ai mis que l'une des classes qui implémentent Filtre.
Le code refuse les lignes : "filtrage(src);
ImageIO.write(filtrage(src), args[3], new File(args[2]));"
puisqu'il ne reconnait pas la méthode.