Modifications apportés
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -64,8 +64,17 @@ $(BIN)/$(PKG_PATH)/util/BitOutputStream.class: $(BIN) \
|
|||||||
|
|
||||||
|
|
||||||
# Compilation des classes mhuffman
|
# Compilation des classes mhuffman
|
||||||
|
|
||||||
|
# Ajout de la classe ComparateurCanonique :
|
||||||
|
$(BIN)/$(PKG_PATH)/mhuffman/ComparateurCanonique.class: $(BIN) \
|
||||||
|
$(SRC)/$(PKG_PATH)/mhuffman/ComparateurCanonique.java
|
||||||
|
$(JAVAC) -cp $(BIN) -d $(BIN) $(SRC)/$(PKG_PATH)/mhuffman/ComparateurCanonique.java
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
$(BIN)/$(PKG_PATH)/mhuffman/CanonicalCode.class: $(BIN) \
|
$(BIN)/$(PKG_PATH)/mhuffman/CanonicalCode.class: $(BIN) \
|
||||||
$(SRC)/$(PKG_PATH)/mhuffman/CanonicalCode.java
|
$(SRC)/$(PKG_PATH)/mhuffman/CanonicalCode.java \
|
||||||
|
$(BIN)/$(PKG_PATH)/mhuffman/ComparateurCanonique.class
|
||||||
$(JAVAC) -cp $(BIN) -d $(BIN) $(SRC)/$(PKG_PATH)/mhuffman/CanonicalCode.java
|
$(JAVAC) -cp $(BIN) -d $(BIN) $(SRC)/$(PKG_PATH)/mhuffman/CanonicalCode.java
|
||||||
|
|
||||||
$(BIN)/$(PKG_PATH)/mhuffman/FrequencyTable.class: $(BIN) \
|
$(BIN)/$(PKG_PATH)/mhuffman/FrequencyTable.class: $(BIN) \
|
||||||
|
|||||||
@@ -19,20 +19,9 @@ public class CanonicalCode{
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// =============== ATTENTION CLASSE ANONYME !!!!!!! ================
|
Collections.sort(liste, new ComparateurCanonique());
|
||||||
Collections.sort(liste, new Comparator<Map.Entry<Integer, String>>() {
|
|
||||||
@Override
|
|
||||||
public int compare(Map.Entry<Integer, String> arg1 ,Map.Entry<Integer, String> arg2) {
|
|
||||||
|
|
||||||
int length1 = arg1.getValue().length();
|
|
||||||
int length2 = arg2.getValue().length();
|
|
||||||
|
|
||||||
if (length1 != length2) {
|
|
||||||
return length1 - length2;
|
|
||||||
}
|
|
||||||
return arg1.getKey() - arg2.getKey();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Map<Integer,String> canonicalCodes = new HashMap<>();
|
Map<Integer,String> canonicalCodes = new HashMap<>();
|
||||||
int code = 0; // code canonique à attribuer
|
int code = 0; // code canonique à attribuer
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package fr.iutfbleau.sae.mhuffman;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ComparateurCanonique implements Comparator<Map.Entry<Integer, String>> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(Map.Entry<Integer, String> entree1,Map.Entry<Integer, String> entree2) {
|
||||||
|
|
||||||
|
int longueur1 = entree1.getValue().length();
|
||||||
|
int longueur2 = entree2.getValue().length();
|
||||||
|
|
||||||
|
if (longueur1 != longueur2) {
|
||||||
|
return longueur1 - longueur2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return entree1.getKey() - entree2.getKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
package fr.iutfbleau.sae.mpif;
|
package fr.iutfbleau.sae.mpif;
|
||||||
|
|
||||||
import fr.iutfbleau.sae.util.BitInputStream;
|
import fr.iutfbleau.sae.util.BitInputStream;
|
||||||
import fr.iutfbleau.sae.util.BitOutputStream;
|
import fr.iutfbleau.sae.util.BitOutputStream;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import fr.iutfbleau.sae.mimage.RGBImage;
|
import fr.iutfbleau.sae.mimage.RGBImage;
|
||||||
|
|
||||||
|
|
||||||
@@ -42,11 +39,26 @@ public class PIFReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void readHeader(BitInputStream in) {
|
public void readHeader(BitInputStream in) {
|
||||||
// TODO: Implement header reading
|
// La largeur et l'hauteur de l'image occupe chaqun deux octets soit 16 bits :
|
||||||
|
this.width = in.readBits(16);
|
||||||
|
this.height = in.readBits(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readCanonicalTables(BitInputStream in) {
|
public void readCanonicalTables(BitInputStream in) {
|
||||||
// TODO: Implement canonical table reading
|
this.lenR = new int[256];
|
||||||
|
this.lenG = new int[256];
|
||||||
|
this.lenB = new int[256];
|
||||||
|
|
||||||
|
for (int i = 0; i < 256; i++){
|
||||||
|
lenR[i] = in.readBits(8);
|
||||||
|
}
|
||||||
|
for (int j = 0; j < 256; j++){
|
||||||
|
lenG[j] = in.readBits(8);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int k = 0; k < 256; k++){
|
||||||
|
lenB[k] = in.readBits(8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String,Integer> rebuildCanonical(int[] lengths) {
|
public Map<String,Integer> rebuildCanonical(int[] lengths) {
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package fr.iutfbleau.sae.vviewer;
|
||||||
|
|
||||||
|
public class ImagePanel extends JPanel{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package fr.iutfbleau.sae.vviewer;
|
||||||
|
|
||||||
|
public class ViewerWindow extends JFrame{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
Reference in New Issue
Block a user