Bonsoir,
voilà j'ai essayé de faire un traitement d'image en utilisant la conversion en grisé
j'ai aussi utilisé la méthode d'invocation RMI mais quand je lance mon serveur on m'affiche cette erreur:
javax.imageio.IIOException: Can't read input file!
at javax.imageio.ImageIO.read(Unknown Source)
at ObjetImplement.NiveauGri(ObjetImplement.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Sou
rce)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Sour
ce)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
et voici mon code
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import javax.imageio.ImageIO;
public class ObjetImplement extends UnicastRemoteObject implements NiveauGris {
private static String inFilename = "test.tif";
/**
* Image de sortie en nuance de gris
*/
private static String outFilename = "Google.png";
protected ObjetImplement() throws RemoteException {
super();
// TODO Auto-generated constructor stub
}
public void NiveauGri() throws RemoteException {
try {
System.out.println("Début de conversion....");
//Ouverture du fichier
File inputFile = new File("test.tif");
BufferedImage imagesrc = ImageIO.read(inputFile);
//Convertion en grisé
BufferedImage imagedst = new BufferedImage(imagesrc.getWidth(), imagesrc.getHeight(), BufferedImage.TYPE_BYTE_GRAY);
Graphics g = imagedst.getGraphics();
g.drawImage(imagesrc, 0, 0, null);
g.dispose();
//Enregistrer l'image au format PNG
File outFile = new File(outFilename);
ImageIO.write(imagedst, "PNG", outFile);
System.out.println("Fin de conversion....");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
e.toString();
}
}
}
quelqu'un sait où est l'erreur parce que moi je vois pas du tout.
Merci à vous