You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 21 година
1234567891011121314151617181920212223242526272829303132
  1. #include <stdio.h>
  2. main(int argc,char **argv)
  3. {
  4. FILE *fin,*fout;
  5. int x,y;
  6. int width,height;
  7. int r,v,g;
  8. fin=fopen(argv[1],"r");
  9. fout=fopen(argv[2],"w");
  10. fscanf(fin,"P3\n");
  11. fscanf(fin,"%d %d\n",&width,&height);
  12. fscanf(fin,"255\n");
  13. fprintf(fout,"png_color cmap[%d][%d]={\n",width,height);
  14. for(y=0;y<height;y++) {
  15. fprintf(fout,"{");
  16. for(x=0;x<width;x++) {
  17. fscanf(fin,"%d\n%d\n%d\n",&r,&v,&g);
  18. fprintf(fout,"{ %d,%d,%d},",r,v,g);
  19. if(x%8==0) fprintf(fout,"\n");
  20. }
  21. fprintf(fout,"},\n");
  22. }
  23. fprintf(fout,"};\n");
  24. fclose(fin);
  25. fclose(fout);
  26. }