1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| // Tampon pour les images
import java.awt.image.BufferedImage;
// Lecture & écriture d'images
import javax.imageio.ImageIO;
// Exceptions et fichiers
import java.io.IOException;
import java.io.File;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Ouverture de l'image BMP...");
try {
// Ouverture fichier
File fichierBMP = new File("test.bmp");
// Récupération du fichier dans un buffer
BufferedImage imageBMP = ImageIO.read(fichierBMP);
// Récupération des dimensions
int largeur = imageBMP.getWidth();
int hauteur = imageBMP.getHeight();
// Allocation matrice
int[] matriceCouleurs = new int[hauteur * largeur];
// Récupération de la matrice
imageBMP.getRGB(0, 0, largeur, hauteur, matriceCouleurs, 0, largeur);
}
catch(IOException exceptIO) {
System.err.println("Erreur !");
}
}
} |
Partager