1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
java.awt.Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
Image image = toolkit.getImage(url);
image = new ImageIcon(image).getImage();
BufferedImage bufferedImage = new BufferedImage(image.getWidth(null),image.getHeight(null),BufferedImage.TYPE_INT_RGB );
Graphics g = bufferedImage.createGraphics();
g.drawImage(image,0,0,null);
g.dispose();
//Lecture de tous les pixels
int w = bufferedImage.getWidth();
int h = bufferedImage.getHeight();
int[] rgbs = new int[w*h];
//On crée l'espace neccessaire
bufferedImage.getRGB(0,0,w,h,rgbs,0,w);
//parcours de mon tableau de pixels
for(int i=1;i<rgbs.length-1;i++)
{
int rouge = (rgbs[i-1] >>16 ) & 0xFF;
int vert = (rgbs[i-1] >> 8 ) & 0xFF;
int bleu = rgbs[i-1] & 0xFF;
} |
Partager