je vous explique mon problème. En gros en ouvrant puis sauvegardant et affichant une image au format ppm je me suis aperçu qu'il y avait une légère différence de couleur et cela fait plusieurs heures que je planche dessus et je ne vois pas d'où vient l'erreur.
D'abord voila l'image originale :
[URL=http://img252.imageshack.us/my.php?image=img10um0.jpg][IMG]http://img252.imageshack.us/img252/217/img10um0.th.jpg[/IMG][/URL]
Puis l'image que j'obtiens après l'avoir ouverte et sauvegardée juste après avec les fonctions que j'ai faite :
[URL=http://img392.imageshack.us/my.php?image=testge2.jpg][IMG]http://img392.imageshack.us/img392/7157/testge2.th.jpg[/IMG][/URL]
Comme vous pouvez le voir il y a des différences de teintes...Au début je pensais avoir inversé une des composantes de couleurs avec une autre mais en faisant des petits tests rapides (créet juste une image toute verte par exemple je me suis aperçu que ce n'était pas ça). Donc voilà si quelqu'un a le temps et souhaite m'aider qu'il soit le bienvenu :
Fonctions utilisées :
inline void ppm_trace(char *function, char *error, char* msg){
printf("[ppm | %s Trace] :: %s (%s)\n", function, error, msg);
exit(1);
}
void ppm_load(char *file_name, float*** matrix_r, float*** matrix_g, float*** matrix_b, int *length, int *width){
FILE *file;
char log[200];
int depth, i,j;
unsigned char color;
file=fopen(file_name, "r");
if(file == NULL)
ppm_trace("ppm_load", "Cannot open file", file_name);
fgets(log, 4, file);
if(strcmp(log, "P6\n"))
ppm_trace("ppm_load", "Bad ppm format", "NOT P6");
fgets(log, 200, file); // Jump GIMP comment (no support of multiline comments)
fscanf(file, "%d %d", width, length);
fscanf(file, "%d", &depth);
*matrix_r = fmatrix_allocate_2d(*length, *width);
*matrix_g = fmatrix_allocate_2d(*length, *width);
*matrix_b = fmatrix_allocate_2d(*length, *width);
for(i=0;i<*length;i++)
for(j=0;j<*width;j++)
{
fread(&color,1,1,file);
(*matrix_r)[i][j] = (float)color;
fread(&color,1,1,file);
(*matrix_g)[i][j] = (float)color;
fread(&color,1,1,file);
(*matrix_b)[i][j] = (float)color;
}
fclose(file);
}
void ppm_save(char* file_name, float **matrix_r, float **matrix_g, float **matrix_b, int length, int width){
FILE *file;
int i, j;
file = fopen(file_name, "w");
if(file == NULL)
ppm_trace("ppm_save", "Cannot open file", file_name);
fprintf(file, "P6\n");
fprintf(file, "# Img generated by ppm_save\n");
fprintf(file, "%d %d\n", width, length);
fprintf(file, "255\n");
for(i=0;i<length;i++)
for(j=0;j<width;j++){
fprintf(file, "%c%c%c", (char)matrix_r[i][j], (char)matrix_g[i][j], (char)matrix_b[i][j]);
}
fclose(file);
}
void ppm_display(char *file_name){
char *tmp = (char*)malloc(sizeof("display &") + strlen(file_name));
if(!tmp)
ppm_trace("ppm_display", "Cannot allocate memory", "NULL");
sprintf(tmp, "display %s&", file_name);
system(tmp);
free(tmp);
}
Et le la fonction principale :
int main(int argc, char** argv)
{
float **matrix_r, **matrix_g, **matrix_b;
int length,width;
ppm_load("img10.ppm",&matrix_r, &matrix_g, &matrix_b, &length, &width);
ppm_save("test.ppm", matrix_r, matrix_g, matrix_b, length, width);
ppm_display("test.ppm");
return 0;
}
Voilà je ne vous demande pas de compiler etc mais si quelqu'un a une idée n'hésitez pas

Merci