erreur avec ArrayIndexOutOfBoundsException
Bonjour,
Mon programme me permet de lire la couleur rouge/vert/bleu d'une surface sur une image.
Et je met ces valeurs dans un tableau.
Pour certaine image j'obtiens ce qu'il faut et pour d'autre j'ai un message d'erreur :
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 35511
ça veut dire quoi ?
voici mon code :
Code:
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
for(double i = 0; i< B;i++){
for(double j =0 ; j<((B-i)/(double)B * H) ; j++){
int a = (int) Math.round(i);
int b = (int) Math.round(j);
int p = imgglobal.getRGB(width- 1-a, height-1-b);
int r = (p>>16)&0xff;
int g = (p>>8)&0xff;
int bl = p&0xff;
listRed.add(r);
listGreen.add(g);
listBlue.add(bl);
}
}
//*** Calcul moyenne Top Right
for(int i=0; i < listRed.size() ; i++)
sommeRed3 = sommeRed3 + listRed.get(i);
double moyRed3 = sommeRed3 / listRed.size();
for(int i=0; i < listGreen.size() ; i++)
sommeGreen3 = sommeGreen3 + listGreen.get(i);
double moyGreen3 = sommeGreen3 / listGreen.size();
for(int i=0; i < listBlue.size() ; i++)
sommeBlue3 = sommeBlue3 + listBlue.get(i);
double moyBlue3 = sommeBlue3 / listBlue.size();
jLabel10.setText("Bottom right: "+ " Red/Green/Blue " + moyRed3 + " / " + moyGreen3 + " / " + moyBlue3 );
int[][] matrice3 = new int[3][col];
for(int j = 0; j< listRed.size();j++){
matrice3[0][j]= listRed.get(j);
matrice3[1][j]= listBlue.get(j);
matrice3[2][j] = listGreen.get(j);
}
for(int i = 0; i<3;i++){
for(int j = 0;j< listRed.size();j++){
System.out.print(matrice3[i][j]+ " ");
}
System.out.println("");
}
System.out.println("*"); |
Merci :)