flut d'octet
This commit is contained in:
BIN
DEV2.1/Flux_octet/Coloriage/Coloriage.class
Normal file
BIN
DEV2.1/Flux_octet/Coloriage/Coloriage.class
Normal file
Binary file not shown.
28
DEV2.1/Flux_octet/Coloriage/Coloriage.java
Normal file
28
DEV2.1/Flux_octet/Coloriage/Coloriage.java
Normal file
@@ -0,0 +1,28 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
|
||||
public class Coloriage extends JComponent{
|
||||
|
||||
public Coloriage(Color couleur){
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setLocation(100,100);
|
||||
fenetre.setSize(500,500);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
fenetre.setVisible(true);
|
||||
try{
|
||||
FileOutputStream fos = new FileOutputStream("couleur.bin");
|
||||
int blue = couleur.getBlue();
|
||||
int red = couleur.getRed();
|
||||
int green = couleur.getGreen();
|
||||
fos.write(blue);
|
||||
fos.write(red);
|
||||
fos.write(green);
|
||||
|
||||
}catch(IOException e){
|
||||
System.err.println("erreur d'ecriture");
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
DEV2.1/Flux_octet/Coloriage/ColoriageTest.class
Normal file
BIN
DEV2.1/Flux_octet/Coloriage/ColoriageTest.class
Normal file
Binary file not shown.
17
DEV2.1/Flux_octet/Coloriage/ColoriageTest.java
Normal file
17
DEV2.1/Flux_octet/Coloriage/ColoriageTest.java
Normal file
@@ -0,0 +1,17 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.awt.Color;
|
||||
|
||||
public class ColoriageTest{
|
||||
|
||||
public static void main(String[] args) {
|
||||
Color couleur = new Color(0,0,0);
|
||||
couleur.decode(args[0]);
|
||||
//String couleur2 = args[1];//
|
||||
Coloriage coloriage = new Coloriage(couleur);
|
||||
}
|
||||
|
||||
}
|
||||
BIN
DEV2.1/Flux_octet/Coloriage/couleur.bin
Normal file
BIN
DEV2.1/Flux_octet/Coloriage/couleur.bin
Normal file
Binary file not shown.
BIN
DEV2.1/Flux_octet/Memoire/Fond.class
Normal file
BIN
DEV2.1/Flux_octet/Memoire/Fond.class
Normal file
Binary file not shown.
44
DEV2.1/Flux_octet/Memoire/Fond.java
Normal file
44
DEV2.1/Flux_octet/Memoire/Fond.java
Normal file
@@ -0,0 +1,44 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Fond extends JPanel implements ActionListener{
|
||||
|
||||
public Fond(){
|
||||
super();
|
||||
// Création des boutons
|
||||
JButton cyanButton = new JButton("Cyan");
|
||||
JButton magentaButton = new JButton("Magenta");
|
||||
JButton yellowButton = new JButton("Jaune");
|
||||
|
||||
// Ajout des action listeners aux boutons
|
||||
cyanButton.addActionListener(this);
|
||||
magentaButton.addActionListener(this);
|
||||
yellowButton.addActionListener(this);
|
||||
|
||||
// Création du panneau pour contrôler la couleur de fond
|
||||
this.add(cyanButton);
|
||||
this.add(magentaButton);
|
||||
this.add(yellowButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String command = e.getActionCommand();
|
||||
switch (command) {
|
||||
case "Cyan":
|
||||
this.setBackground(Color.CYAN);
|
||||
break;
|
||||
case "Magenta":
|
||||
this.setBackground(Color.MAGENTA);
|
||||
break;
|
||||
case "Jaune":
|
||||
this.setBackground(Color.YELLOW);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
BIN
DEV2.1/Flux_octet/Memoire/Memoire.class
Normal file
BIN
DEV2.1/Flux_octet/Memoire/Memoire.class
Normal file
Binary file not shown.
70
DEV2.1/Flux_octet/Memoire/Memoire.java
Normal file
70
DEV2.1/Flux_octet/Memoire/Memoire.java
Normal file
@@ -0,0 +1,70 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
|
||||
public class Memoire extends JFrame implements WindowListener{
|
||||
public void windowClosed(WindowEvent evenement){}
|
||||
public void windowActivated(WindowEvent evenement){}
|
||||
public void windowClosing(WindowEvent evenement){
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream("position.bin");
|
||||
DataOutputStream dos = new DataOutputStream(fos);
|
||||
|
||||
int w = this.getWidth();
|
||||
int h = this.getHeight();
|
||||
int x = this.getX();
|
||||
int y = this.getY();
|
||||
|
||||
dos.writeInt(x);
|
||||
dos.writeInt(y);
|
||||
dos.writeInt(h);
|
||||
dos.writeInt(w);
|
||||
System.out.println("info stockee");
|
||||
|
||||
|
||||
this.dispose();
|
||||
}catch(Exception e){
|
||||
System.out.println("erreur stockage");
|
||||
}
|
||||
|
||||
}
|
||||
public void windowDeactivated(WindowEvent evenement){}
|
||||
public void windowDeiconified(WindowEvent evenement){}
|
||||
public void windowIconified(WindowEvent evenement){}
|
||||
public void windowOpened(WindowEvent evenement){}
|
||||
|
||||
|
||||
public Memoire(){
|
||||
super();
|
||||
|
||||
|
||||
try {
|
||||
FileInputStream fis = new FileInputStream("position.bin");
|
||||
DataInputStream dis = new DataInputStream(fis);
|
||||
int x = dis.readInt();
|
||||
int y = dis.readInt();
|
||||
int h = dis.readInt();
|
||||
int w = dis.readInt();
|
||||
|
||||
this.setLocation(x,y);
|
||||
this.setSize(w,h);
|
||||
|
||||
}catch(Exception e){
|
||||
System.out.println("Ouverture par defaut");
|
||||
this.setLocation(100, 100);
|
||||
this.setSize(500,500);
|
||||
}
|
||||
|
||||
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||
|
||||
Fond fond = new Fond();
|
||||
this.add(fond);
|
||||
|
||||
this.setVisible(true);
|
||||
this.addWindowListener(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BIN
DEV2.1/Flux_octet/Memoire/Test_memoire.class
Normal file
BIN
DEV2.1/Flux_octet/Memoire/Test_memoire.class
Normal file
Binary file not shown.
13
DEV2.1/Flux_octet/Memoire/Test_memoire.java
Normal file
13
DEV2.1/Flux_octet/Memoire/Test_memoire.java
Normal file
@@ -0,0 +1,13 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Test_memoire {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Memoire memoire = new Memoire();
|
||||
|
||||
}
|
||||
}
|
||||
BIN
DEV2.1/Flux_octet/Memoire/position.bin
Normal file
BIN
DEV2.1/Flux_octet/Memoire/position.bin
Normal file
Binary file not shown.
BIN
DEV2.1/Flux_octet/image/Imagee.class
Normal file
BIN
DEV2.1/Flux_octet/image/Imagee.class
Normal file
Binary file not shown.
40
DEV2.1/Flux_octet/image/Imagee.java
Normal file
40
DEV2.1/Flux_octet/image/Imagee.java
Normal file
@@ -0,0 +1,40 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.io.*;
|
||||
|
||||
public class Imagee extends JComponent {
|
||||
|
||||
private Image image;
|
||||
|
||||
public Imagee(int width, int height, String path) throws IOException{
|
||||
image = readFromFile (width, height, path);
|
||||
setPreferredSize(new Dimension(width, height));
|
||||
}
|
||||
|
||||
private Image readFromFile (int width, int height, String path) throws IOException{
|
||||
FileInputStream input = new FileInputStream(path);
|
||||
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
|
||||
byte[] read_buffer = new byte[width * height * 3];
|
||||
input.read(read_buffer);
|
||||
|
||||
int[] int_buffer = new int[read_buffer.length];
|
||||
for (int i = 0;i < read_buffer.length ; i++)
|
||||
int_buffer[i] = read_buffer[i] & 0xFF;
|
||||
img.getRaster().setPixels(0,0,width,height,int_buffer);
|
||||
|
||||
return img;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics pinceau){
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
if (this.isOpaque()) {
|
||||
secondPinceau.setColor(this.getBackground());
|
||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
secondPinceau.setColor(this.getForeground());
|
||||
secondPinceau.drawImage(image, 0 ,0 , this);
|
||||
}
|
||||
}
|
||||
BIN
DEV2.1/Flux_octet/image/ImgTest.class
Normal file
BIN
DEV2.1/Flux_octet/image/ImgTest.class
Normal file
Binary file not shown.
27
DEV2.1/Flux_octet/image/ImgTest.java
Normal file
27
DEV2.1/Flux_octet/image/ImgTest.java
Normal file
@@ -0,0 +1,27 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
|
||||
public class ImgTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
JFrame fenetre = new JFrame("Image");
|
||||
fenetre.setSize(768,1024);
|
||||
fenetre.setLocationRelativeTo(null);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
try{
|
||||
Imagee img = new Imagee(768, 1024,"image.bin");
|
||||
fenetre.add(img);
|
||||
}catch(IOException e){
|
||||
System.out.println("probleme");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
fenetre.setVisible(true);
|
||||
|
||||
}
|
||||
}
|
||||
BIN
DEV2.1/Flux_octet/image/image.bin
Normal file
BIN
DEV2.1/Flux_octet/image/image.bin
Normal file
Binary file not shown.
Reference in New Issue
Block a user