Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1821 connectés 

  FORUM HardWare.fr
  Programmation
  Java

  besoin d'aide en java ?

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

besoin d'aide en java ?

n°1580136
dodo
Posté le 27-06-2007 à 21:50:37  profilanswer
 

bonjour,
 
je suis en train de faire un petit projet mais là je cale il faut dire que la prog je toruve ça hard.
 
voilà je dois lire un fichier image ppm pour pouvoir le modifier.
 
déjà je comprend pas pourquoi cette ligne ne  compile pas im.pixels=s;
 
 

Code :
  1. class Image{
  2. String nom;
  3. String commentaire;
  4. String largeur ;
  5. String hauteur;
  6. String indiceCouleur;
  7. ListeSegment pixels=new ListeSegment();
  8. public Image   lireImage(){
  9.  Image im=new Image();
  10.  String nomFichier;
  11.  String s;
  12.  FileInputStream fichier;
  13.  int c=0;
  14.  Terminal.ecrireStringln("Entrer le nom de l'image à ouvrir :" );
  15.  nomFichier=Terminal.lireString();
  16.  try{
  17.  fichier=new FileInputStream(nomFichier);
  18.  //lecture de du P3
  19.  s=lireLigne(fichier);
  20.  im.nom=s;
  21.  Terminal.sautDeLigne();
  22.  //lecture de la ligne commantaire
  23.  s=lireLigne(fichier);
  24.  im.commentaire=s;
  25.  Terminal.sautDeLigne();
  26.  //lecture de la largeur
  27.  do{
  28.   Terminal.ecrireChar((char) c);
  29.   s+=(char)c;
  30.   c=fichier.read();
  31.  }while((c!=' ')&&(c!='\r')&&(c!='\n'));
  32.  im.largeur=s;
  33.  //lecture de la hauteur
  34.  do{
  35.   Terminal.ecrireChar((char) c);
  36.   s+=(char)c;
  37.   c=fichier.read();
  38.  }while((c!=' ')&&(c!='\r')&&(c!='\n'));
  39.  im.hauteur=s;
  40.  Terminal.sautDeLigne();
  41.  // lecture de la nuance
  42.  do{
  43.   Terminal.ecrireChar((char) c);
  44.   s+=(char)c;
  45.   c=fichier.read();
  46.  }while((c!=' ')&&(c!='\r')&&(c!='\n'));
  47.  im.indiceCouleur=s;
  48.  Terminal.sautDeLigne();
  49.  //lecture des segments
  50.  do{
  51.   Terminal.ecrireChar((char) c);
  52.   s+=(char)c;
  53.   c=fichier.read();
  54.  }while((c!=' ')&&(c!='\r')&&(c!='\n'));
  55.  Terminal.sautDeLigne();
  56.  im.pixels=s;
  57.  fichier.close();
  58.  }catch(FileNotFoundException ex){
  59.  Terminal.ecrireStringln("Ce fichier n'existe pas" );
  60.  }catch(IOException exc){
  61.  Terminal.ecrireStringln("Erreur d'entre-sortie" );
  62.  }
  63.  return im;
  64. }
  65. //permet lecture de la ligne jusqu'au caractère de fin de ligne
  66. static String lireLigne(FileInputStream fichier)throws FileNotFoundException, IOException{
  67.  int c=0;
  68.  String s="";
  69.  do {
  70.   Terminal.ecrireChar((char) c);
  71.  c=fichier.read();
  72.  } while((c!='\r')&&(c!='\n'));
  73.  s+=(char)c;
  74.  return s;
  75. }
  76. //permet la lecture de la ligne  
  77. static String lireLigne2(FileInputStream fichier)throws FileNotFoundException, IOException{
  78.  int c=0;
  79.  String s="";
  80.  do {
  81.   Terminal.ecrireChar((char) c);
  82.  c=fichier.read();
  83.  }while((c!=' ')&&(c!='\r')&&(c!='\n'));
  84.  s+=(char)c;
  85.  return s;
  86. }
  87. // Affichage du Menu
  88. static void  Menu(){
  89.  Terminal.ecrireStringln("======================================" );
  90. Terminal.ecrireStringln("===============MENU ==================" );
  91.  Terminal.ecrireStringln("======================================" );
  92.  Terminal.ecrireStringln("1. Ouvrir une image" );
  93.  Terminal.ecrireStringln("......................................" );
  94.  Terminal.ecrireStringln("2. Quitter                                                                                      " );
  95.  Terminal.ecrireStringln("======================================" );
  96. }
  97. //Permet à l'utilisateur de faire sont choix dans le menu
  98. static int  ChoixMenu(){
  99.  int choix=0;
  100.  do{
  101.   Terminal.ecrireString(" Faites votre choix " );
  102.   choix=Terminal.lireInt();
  103.  }while(choix<1||choix>3);
  104.  return choix;
  105. }
  106. // On récupère le choix de l'utilisateur
  107. static void reponseMenu(int choix){
  108.  switch(choix){
  109.   case 1: {
  110.    OuvrirImage();
  111.    break;
  112.   }
  113.   case 2: {
  114.    System.exit(0);
  115.    break;
  116.   }
  117.   default:{
  118.    Terminal.ecrireStringln(" faite un choix entre 1 et 2" );
  119.    Menu();
  120.   }
  121.  }
  122. }
  123. static void OuvrirImage(){
  124.  String nomFichier;
  125.  FileInputStream fichier;
  126.  int c=0;
  127.  Terminal.ecrireStringln("Entrer le nom de l'image:" );
  128.  nomFichier=Terminal.lireString();
  129.  try{
  130.  fichier=new FileInputStream(nomFichier);
  131.  c=fichier.read();
  132.  while(c!=-1){
  133.   //Terminal.ecrireChar((char) c);
  134.   c=fichier.read();
  135.  }
  136.  fichier.close();
  137.  }catch(FileNotFoundException ex){
  138.  Terminal.ecrireStringln("Ce fichier n'existe pas" );
  139.  }catch(IOException exc){
  140.  Terminal.ecrireStringln("Erreur d'entre-sortie" );
  141.  }
  142. }
  143. }
  144. class ListeSegment{
  145. int rouge;
  146. int vert;
  147. int bleu;
  148. ListeSegment suivant=null;
  149. int comptSegment=0;
  150. public ListeSegment(){
  151. }
  152. public ListeSegment( int r, int v, int b,int compt){
  153.  this.rouge=r;
  154.  this.vert=v;
  155.  this.bleu=b;
  156.  this.comptSegment=compt;
  157. }
  158. public ListeSegment ajouterListeSegment( int r, int v,int b, int compt){
  159.  ListeSegment S =new ListeSegment(r,v,b, compt);
  160.  this.suivant=S;
  161.  return S;
  162. }
  163. }


 

mood
Publicité
Posté le 27-06-2007 à 21:50:37  profilanswer
 

n°1580550
wapcamer
Posté le 28-06-2007 à 19:15:11  profilanswer
 

ListeSegment pixels;
String s;
 
voilà pq ca compile pas.


---------------
Voir les RAW sous Android: https://market.android.com/details? [...] .RawVision Blog Photo: http://photouch.me Applications mobiles: http://caketuzz.com Wapcam Project: http://wapcam.mobi
n°1580552
dodo
Posté le 28-06-2007 à 19:29:58  profilanswer
 

c'est a dire  ? pourrais  tu m'expliqué mon erreur

n°1580559
zapan666
Tout est relatif
Posté le 28-06-2007 à 20:11:55  profilanswer
 

dodo a écrit :

c'est a dire  ? pourrais  tu m'expliqué mon erreur


les types de s et pixels sont différents (cf le message au dessus)


---------------
my flick r - Just Tab it !
n°1580563
dodo
Posté le 28-06-2007 à 20:52:05  profilanswer
 

ok !!! mais comment je peux remedier ceci.
 
de plus  si je fais juste im.pixels; j'ai cette erreur donc je comprend pas non plus not a statement

n°1580571
dodo
Posté le 28-06-2007 à 22:09:46  profilanswer
 


 
 
j'essaye de la laire vi cette ligne de code

Code :
  1. #
  2. //lecture des segments
  3. #
  4.         do{   
  5.             Terminal.ecrireChar((char) c);
  6.             s+=(char)c;
  7.             c=fichier.read();
  8.         }while((c!=' ')&&(c!='\r')&&(c!='\n'));
  9.         Terminal.sautDeLigne();
  10.         im.pixels=s;


 
 
qui doit me donner  quelque chose du type 255 dont chaque  chiffre correspond au couleur en question.
 
et ça j'arrive pas les mettre dans im.pixels


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Java

  besoin d'aide en java ?

 

Sujets relatifs
Java Mysql besoin d'aideBesoin d'aide, conseil Jsp, java
[java] debutant besoin d'aide pour interface graphBesoin d'aide pour traiter une image en java
besoin d'aide pour executer du java[Java] Besoin d'aide pour petits progs de debutante
Java-Oracle et JSp besoin d'aide [RESOLU]Application Java et Single Document Interface : besoin d'aide
[JAVA] - Tester la non nullité d'un champ - Besoin Aide 1 min maxi ![Java] besoin d'aide bidouillage BigInteger BigDecimal
Plus de sujets relatifs à : besoin d'aide en java ?


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR