44 lines
942 B
Java
44 lines
942 B
Java
import java.io.*;
|
|
import javax.swing.*;
|
|
import java.awt.*;
|
|
|
|
public class Image {
|
|
public static void main(String[] args) {
|
|
//ouverture du fichier
|
|
try
|
|
{
|
|
FileInputStream fos = new FileInputStream("image.bin");
|
|
}
|
|
catch(IOException e)
|
|
{
|
|
System.out.println("Erreur Ouverture du fichier");
|
|
}
|
|
try
|
|
{
|
|
BufferedImage img = new BufferedImage(768,1024,BufferedImage.TYPE_3BYTE_BGR);
|
|
for(int x = 0;x<768;x++)
|
|
{
|
|
for(int y = 0;y<1024;y++)
|
|
{
|
|
int r = input.read();
|
|
int g = input.read();
|
|
int b = input.read();
|
|
int rgb = (r<<16)|(g<<8)|(b);
|
|
img setRGB(x,y,rgb);
|
|
}
|
|
}
|
|
}
|
|
catch( IOException e)
|
|
{
|
|
System.out.println("Erreur Lecture du fichier");
|
|
}
|
|
|
|
Frame frame = new JFrame();
|
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
JLabel image = new JLabel(new ImageIcon(img));
|
|
frame.add(image);
|
|
frame.pack();
|
|
frame.setVisible(true);
|
|
|
|
}
|
|
} |