Controle machine
This commit is contained in:
BIN
DEV2.1/TP11/01_Image/Fenetre.class
Normal file
BIN
DEV2.1/TP11/01_Image/Fenetre.class
Normal file
Binary file not shown.
12
DEV2.1/TP11/01_Image/Fenetre.java
Normal file
12
DEV2.1/TP11/01_Image/Fenetre.java
Normal file
@@ -0,0 +1,12 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Fenetre extends JFrame {
|
||||
public Fenetre() {
|
||||
this.setSize(768, 1024);
|
||||
this.setLocation(100, 100);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.setLayout(new GridLayout(1, 1));
|
||||
this.add(new Image());
|
||||
}
|
||||
}
|
BIN
DEV2.1/TP11/01_Image/Image.class
Normal file
BIN
DEV2.1/TP11/01_Image/Image.class
Normal file
Binary file not shown.
19
DEV2.1/TP11/01_Image/Image.java
Normal file
19
DEV2.1/TP11/01_Image/Image.java
Normal file
@@ -0,0 +1,19 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
|
||||
public class Image extends JComponent {
|
||||
@Override
|
||||
public void paintComponent(Graphics pinceau) {
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
Color couleur;
|
||||
|
||||
if (this.isOpaque()) {
|
||||
secondPinceau.setColor(this.getBackground());
|
||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
|
||||
secondPinceau.drawImage(new LectureFichier().getImage(), 0, 0, this);
|
||||
|
||||
}
|
||||
}
|
BIN
DEV2.1/TP11/01_Image/LectureFichier.class
Normal file
BIN
DEV2.1/TP11/01_Image/LectureFichier.class
Normal file
Binary file not shown.
52
DEV2.1/TP11/01_Image/LectureFichier.java
Normal file
52
DEV2.1/TP11/01_Image/LectureFichier.java
Normal file
@@ -0,0 +1,52 @@
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class LectureFichier {
|
||||
|
||||
private BufferedImage image;
|
||||
|
||||
public LectureFichier() {
|
||||
this.image = new BufferedImage(768, 1024, BufferedImage.TYPE_3BYTE_BGR);
|
||||
int r;
|
||||
int g;
|
||||
int b;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
Color couleur;
|
||||
|
||||
try {
|
||||
FileInputStream fichier = new FileInputStream("image.bin");
|
||||
|
||||
while(fichier.available() >= 3) {
|
||||
try {
|
||||
r = fichier.read();
|
||||
g = fichier.read();
|
||||
b = fichier.read();
|
||||
couleur = new Color(r, g, b);
|
||||
this.image.setRGB(i, j, couleur.getRGB());
|
||||
i++;
|
||||
if (i >= 768) {
|
||||
j++;
|
||||
i = 0;
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
System.out.println("Erreur d'accès");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
fichier.close();
|
||||
} catch (IOException e3) {
|
||||
System.out.println("Erreur de fermeture");
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
System.out.println("Erreur d'ouverture");
|
||||
}
|
||||
}
|
||||
|
||||
public BufferedImage getImage() {
|
||||
return this.image;
|
||||
}
|
||||
|
||||
}
|
BIN
DEV2.1/TP11/01_Image/Main.class
Normal file
BIN
DEV2.1/TP11/01_Image/Main.class
Normal file
Binary file not shown.
6
DEV2.1/TP11/01_Image/Main.java
Normal file
6
DEV2.1/TP11/01_Image/Main.java
Normal file
@@ -0,0 +1,6 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Fenetre fenetre = new Fenetre();
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
1
DEV2.1/TP11/01_Image/couleur.bin
Normal file
1
DEV2.1/TP11/01_Image/couleur.bin
Normal file
File diff suppressed because one or more lines are too long
BIN
DEV2.1/TP11/01_Image/image.bin
Normal file
BIN
DEV2.1/TP11/01_Image/image.bin
Normal file
Binary file not shown.
Reference in New Issue
Block a user