OVH Cloud OVH Cloud

un vrai mystere

7 réponses
Avatar
brack romain
bonjour,

je planche sur un vrai mystere.
tout d'abord ma méthode :

----------------------------------------------------------------------------
------------------
private void creationTableau()
{
/*
* creation des tableau
*/
this.tab_hexa = new String[216];
this.tab_rgb = new int[216][3];
String tab_code[] = {"00","33","66","99","CC","FF"};

/*
* construction du tableau
*/
int compteur = 0;
// parse le rouge
for (int r=0 ; r<=5 ; r++)
{
// parse le vert
for (int g=0 ; g<=5 ; g++)
{
// parse le bleu
for (int b=0 ; b<=5 ; b++)
{
// met le code hexa dans le tableau
this.tab_hexa[compteur] = tab_code[r]+tab_code[g]+tab_code[b];

/*
* me les code rgb dans le tableau
*/
this.tab_rgb[compteur][0] = Integer.parseInt(tab_code[r], 16);
this.tab_rgb[compteur][1] = Integer.parseInt(tab_code[g], 16);
this.tab_rgb[compteur][2] = Integer.parseInt(tab_code[b], 16);

// augmente le compteur
compteur++;
}
}
}
}
----------------------------------------------------------------------------
---------------------


mon probleme est que Integer.parseInt(tab_code[r-g-b], 16); retourne 0 a
chaque fois
mais si je fais
Integer.parseInt("FF", 16); ou
Integer.parseInt("33", 16); ou autre sa fonctionne !

je suis perdu je sais pas comment m'y prendre

merci d'avance

7 réponses

Avatar
Damien GUERIN
Tu dois d'abord regarder si le probleme vient de ton tableau où de ta façon
de l'utiliser.
Que renvoie :
Integer.parseInt(tab_code[5], 16); ??
tab_code[5] ?
tab_code[r] ?
etc...
A 1ere vue, je sais pas. Mais etre qu'avec mes questions...

A+

"brack romain" a écrit dans le message de news:
df54e$43021568$52aecc07$
bonjour,

je planche sur un vrai mystere.
tout d'abord ma méthode :

----------------------------------------------------------------------------
------------------
private void creationTableau()
{
/*
* creation des tableau
*/
this.tab_hexa = new String[216];
this.tab_rgb = new int[216][3];
String tab_code[] = {"00","33","66","99","CC","FF"};

/*
* construction du tableau
*/
int compteur = 0;
// parse le rouge
for (int r=0 ; r<=5 ; r++)
{
// parse le vert
for (int g=0 ; g<=5 ; g++)
{
// parse le bleu
for (int b=0 ; b<=5 ; b++)
{
// met le code hexa dans le tableau
this.tab_hexa[compteur] = tab_code[r]+tab_code[g]+tab_code[b];

/*
* me les code rgb dans le tableau
*/
this.tab_rgb[compteur][0] = Integer.parseInt(tab_code[r], 16);
this.tab_rgb[compteur][1] = Integer.parseInt(tab_code[g], 16);
this.tab_rgb[compteur][2] = Integer.parseInt(tab_code[b], 16);

// augmente le compteur
compteur++;
}
}
}
}
----------------------------------------------------------------------------
---------------------


mon probleme est que Integer.parseInt(tab_code[r-g-b], 16); retourne 0 a
chaque fois
mais si je fais
Integer.parseInt("FF", 16); ou
Integer.parseInt("33", 16); ou autre sa fonctionne !

je suis perdu je sais pas comment m'y prendre

merci d'avance







Avatar
Patrick Gras
Le mystère est ailleurs, ça fonctionne très bien chez moi :)

(Copié-collé de ton code)

-Patrick

"brack romain" wrote in message
news:df54e$43021568$52aecc07$
bonjour,

je planche sur un vrai mystere.
tout d'abord ma méthode :

--------------------------------------------------------------------------
--

------------------
private void creationTableau()
{
/*
* creation des tableau
*/
this.tab_hexa = new String[216];
this.tab_rgb = new int[216][3];
String tab_code[] = {"00","33","66","99","CC","FF"};

/*
* construction du tableau
*/
int compteur = 0;
// parse le rouge
for (int r=0 ; r<=5 ; r++)
{
// parse le vert
for (int g=0 ; g<=5 ; g++)
{
// parse le bleu
for (int b=0 ; b<=5 ; b++)
{
// met le code hexa dans le tableau
this.tab_hexa[compteur] = tab_code[r]+tab_code[g]+tab_code[b];

/*
* me les code rgb dans le tableau
*/
this.tab_rgb[compteur][0] = Integer.parseInt(tab_code[r], 16);
this.tab_rgb[compteur][1] = Integer.parseInt(tab_code[g], 16);
this.tab_rgb[compteur][2] = Integer.parseInt(tab_code[b], 16);

// augmente le compteur
compteur++;
}
}
}
}
--------------------------------------------------------------------------
--

---------------------


mon probleme est que Integer.parseInt(tab_code[r-g-b], 16); retourne 0 a
chaque fois
mais si je fais
Integer.parseInt("FF", 16); ou
Integer.parseInt("33", 16); ou autre sa fonctionne !

je suis perdu je sais pas comment m'y prendre

merci d'avance







Avatar
brack romain
ce serait possible que c'est une histoire de versions ?

j'ai essayer qu'avec l'applet viewer, je vais essayer sur une page html ...
Avatar
brack romain
j'ai essayer avec le navigateur mais sans resultat ...
peut etre une histoire de version ...
Avatar
Patrick Gras
Question bête: Es-tu sûr d'appeler creationTableau ???

-Patrick

"brack romain" wrote in message
news:6f8ef$4302e9b3$52aecc07$
ce serait possible que c'est une histoire de versions ?

j'ai essayer qu'avec l'applet viewer, je vais essayer sur une page html
...





Avatar
brack romain
Avatar
brack romain
j'ai trouve !!

j'ai honte ...

voici ce que je faisait :
System.out.println("000000 -> "+this.tab_hexa[0]+" ->
"+this.tab_rgb[0][0]+","+this.tab_rgb[0][1]+","+this.tab_rgb[0][2]);
System.out.println("006600 -> "+this.tab_hexa[12]+" ->
"+this.tab_rgb[0][0]+","+this.tab_rgb[0][1]+","+this.tab_rgb[0][2]);
System.out.println("6600ff -> "+this.tab_hexa[77]+" ->
"+this.tab_rgb[0][0]+","+this.tab_rgb[0][1]+","+this.tab_rgb[0][2]);

et il faut faire :
System.out.println("000000 -> "+this.tab_hexa[0]+" ->
"+this.tab_rgb[0][0]+","+this.tab_rgb[0][1]+","+this.tab_rgb[0][2]);
System.out.println("006600 -> "+this.tab_hexa[12]+" ->
"+this.tab_rgb[12][0]+","+this.tab_rgb[12][1]+","+this.tab_rgb[12][2]);
System.out.println("6600ff -> "+this.tab_hexa[77]+" ->
"+this.tab_rgb[77][0]+","+this.tab_rgb[77][1]+","+this.tab_rgb[77][2]);


le pointeru je le laissais a 0 dans la 1er colonne ...

excusez moi je suis un boulet ...