1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| public static void versJpg(String nomFichier, int[] emotions, int largeurLignes) throws IOException{
int mult = 4; //Math.min(500/largeurLignes, 500*largeurLignes/agents.size());
BufferedImage img = new BufferedImage(largeurLignes*mult, emotions.length*mult/largeurLignes, BufferedImage.TYPE_INT_RGB);
for (int j = 0; j < emotions.length/largeurLignes; j++) {
for (int i = 0; i < largeurLignes; i++) {
int couleur = COULEURS[emotions[i + j*largeurLignes]].getRGB();
for (int x = 0; x < mult; x++) {
for (int y = 0; y < mult; y++) {
img.setRGB(i*mult + x, j*mult + y, couleur);
}
}
}
}
if (new File(nomFichier + ".jpg").exists()) {
new File(nomFichier + ".jpg").delete();
}
ImageIO.write(img, "JPG", new File(nomFichier + ".jpg"));
} |
Partager