This commit is contained in:
Simoes Lukas
2025-03-27 13:35:54 +01:00
parent 376861b608
commit fe693705bf
90 changed files with 1188 additions and 24 deletions

View File

@@ -16,7 +16,7 @@ public class LectureFichier {
Color couleur;
try {
FileInputStream fichier = new FileInputStream("image.bin");
FileInputStream fichier = new FileInputStream("couleur.bin");
while(fichier.available() >= 3) {
try {

Binary file not shown.

View File

@@ -3,22 +3,22 @@ import java.io.*;
public class EcritureFichier {
private byte r;
private byte g;
private byte b;
private int r;
private int g;
private int b;
private byte r2;
private byte g2;
private byte b2;
private int r2;
private int g2;
private int b2;
public EcritureFichier(byte r, byte g, byte b) {
public EcritureFichier(int r, int g, int b) {
this.r = r;
this.g = g;
this.b = b;
try {
FileOutputStream fichier = new FileOutputStream("couleur.bin");
System.out.println(r + " " + g + " " + b);
try {
for (int i = 0; i != 768; i++) {
for (int j = 0; j != 1024; j++) {
@@ -42,7 +42,7 @@ public class EcritureFichier {
}
}
public EcritureFichier(byte r, byte g, byte b, byte r2, byte g2, byte b2) {
public EcritureFichier(int r, int g, int b, int r2, int g2, int b2) {
this.r = r;
this.g = g;
this.b = b;
@@ -52,15 +52,42 @@ public class EcritureFichier {
try {
FileOutputStream fichier = new FileOutputStream("couleur.bin");
int choixR = r;
int choixG = g;
int choixB = b;
try {
for (int i = 0; i != 768; i++) {
for (int j = 0; j != 1024; j++) {
fichier.write(r);
fichier.write(g);
fichier.write(b);
for (int l = 0; l != 8; l++) {
for (int k = 0; k != 8; k++) {
for (int i = 0; i != 768/8; i++) {
for (int j = 0; j != 1024/8; j++) {
fichier.write(choixR);
fichier.write(choixG);
fichier.write(choixB);
}
if (choixR == r) {
choixR = r2;
choixG = g2;
choixB = b2;
}
else {
choixR = r;
choixG = g;
choixB = b;
}
}
}
}
if (choixR == r) {
choixR = r2;
choixG = g2;
choixB = b2;
}
else {
choixR = r;
choixG = g;
choixB = b;
}
}
} catch (IOException e2) {
System.out.println("Erreur d'écriture");
}

Binary file not shown.

View File

@@ -1,11 +1,21 @@
public class Main {
public static void main(String[] args) {
String chaineCouleur = args[0].replaceAll("#", "");
Integer r = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(0, 2), 16));
Integer g = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(2, 4), 16));
Integer b = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(4, 6), 16));
if (args.length == 1) {
String chaineCouleur = args[0].replaceAll("#", "");
Integer r = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(0, 2), 16));
Integer g = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(2, 4), 16));
Integer b = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(4, 6), 16));
EcritureFichier ecriture = new EcritureFichier(r.byteValue(), g.byteValue(), b.byteValue());
EcritureFichier ecriture = new EcritureFichier(r, g, b);
}
else if (args.length == 2) {
String chaineCouleur2 = args[1].replaceAll("#", "");
Integer r2 = Integer.valueOf(Integer.parseInt(chaineCouleur2.substring(0, 2), 16));
Integer g2 = Integer.valueOf(Integer.parseInt(chaineCouleur2.substring(2, 4), 16));
Integer b2 = Integer.valueOf(Integer.parseInt(chaineCouleur2.substring(4, 6), 16));
System.out.println(r + "," + g + "," + b + " | " + r2 + "," + g2 + "," + b2);
EcritureFichier ecriture2 = new EcritureFichier(r, g, b, r2, g2, b2);
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,108 @@
import java.awt.*;
import java.io.*;
public class EcritureFichier {
private int r;
private int g;
private int b;
private int r2;
private int g2;
private int b2;
public EcritureFichier(int r, int g, int b) {
this.r = r;
this.g = g;
this.b = b;
try {
FileOutputStream fichier = new FileOutputStream("couleur.bin");
System.out.println(r + " " + g + " " + b);
try {
for (int i = 0; i != 768; i++) {
for (int j = 0; j != 1024; j++) {
fichier.write(r);
fichier.write(g);
fichier.write(b);
}
}
} catch (IOException e2) {
System.out.println("Erreur d'écriture");
}
try {
fichier.close();
} catch (IOException e3) {
System.out.println("Erreur de fermeture");
}
} catch (IOException e) {
System.out.println("Erreur d'ouverture");
}
}
public EcritureFichier(int r, int g, int b, int r2, int g2, int b2) {
this.r = r;
this.g = g;
this.b = b;
this.r2 = r2;
this.g2 = g2;
this.b2 = b2;
try {
FileOutputStream fichier = new FileOutputStream("couleur.bin");
int choixR = r;
int choixG = g;
int choixB = b;
try {
for (int l = 0; l != 8; l++) {
for (int k = 0; k != 8; k++) {
for (int i = 0; i != 768/8; i++) {
for (int j = 0; j != 1024/8; j++) {
fichier.write(choixR);
fichier.write(choixG);
fichier.write(choixB);
}
if (choixR == r) {
choixR = r2;
choixG = g2;
choixB = b2;
}
else {
choixR = r;
choixG = g;
choixB = b;
}
}
}
if (choixR == r) {
choixR = r2;
choixG = g2;
choixB = b2;
}
else {
choixR = r;
choixG = g;
choixB = b;
}
}
} catch (IOException e2) {
System.out.println("Erreur d'écriture");
}
try {
fichier.close();
} catch (IOException e3) {
System.out.println("Erreur de fermeture");
}
} catch (IOException e) {
System.out.println("Erreur d'ouverture");
}
}
}

View 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());
}
}

View 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);
}
}

View 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("couleur.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;
}
}

View File

@@ -0,0 +1,6 @@
public class Main {
public static void main(String[] args) {
Fenetre fenetre = new Fenetre();
fenetre.setVisible(true);
}
}

Binary file not shown.

Binary file not shown.