Files
SAE32_2025/src/fr/iutfbleau/sae/mpif/PIFReader.java
T

71 lines
1.9 KiB
Java
Raw Normal View History

2026-01-02 20:52:44 +01:00
package fr.iutfbleau.sae.mpif;
import fr.iutfbleau.sae.util.BitInputStream;
import fr.iutfbleau.sae.util.BitOutputStream;
import java.io.FileInputStream;
import java.util.Map;
import fr.iutfbleau.sae.mimage.RGBImage;
public class PIFReader {
private int width;
private int height;
private int[] lenR;
private int[] lenG;
private int[] lenB;
public RGBImage read(String filepath)
throws Exception {
FileInputStream fis = new FileInputStream(filepath);
BitInputStream lecteur = new BitInputStream(fis);
// je lis l'entête et les tables canoniques
this.readHeader(lecteur);
this.readCanonicalTables(lecteur);
// je reconstructe les tables canoniques car dans le fichier on a juste les longueurs en bits
Map<String, Integer> canonR = rebuildCanonical(lenR);
Map<String, Integer> canonG = rebuildCanonical(lenG);
Map<String, Integer> canonB = rebuildCanonical(lenB);
DecodeNode trieR = buildDecodageTree(canonR);
DecodeNode trieG = buildDecodageTree(canonG);
DecodeNode trieB = buildDecodageTree(canonB);
RGBImage img = decodePixels(lecteur, trieR, trieG, trieB);
lecteur.closeFlux();
return img;
}
public void readHeader(BitInputStream in) {
// TODO: Implement header reading
}
public void readCanonicalTables(BitInputStream in) {
// TODO: Implement canonical table reading
}
public Map<String,Integer> rebuildCanonical(int[] lengths) {
// TODO: Implement canonical table reconstruction
return null;
}
public RGBImage decodePixels(BitInputStream in, DecodeNode red, DecodeNode green, DecodeNode blue) {
// TODO: Implement pixel decoding
return null;
}
public DecodeNode buildDecodageTree(Map<String,Integer> codes) {
// TODO: Implement trie building
return null;
}
}