Advertisement
shouhei

color2

Nov 6th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1.  
  2. #include<stdio.h>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. //Decralation of variables
  7. FILE *fpi,*fpo;
  8. int id,ix,iy;
  9. float x,y,z;
  10. char nan[4];
  11. unsigned char *buffer; /*入力画像用メモリのポインタ*/
  12. unsigned char *buffer2; /*出力画像用メモリのポインタ*/
  13. unsigned char *Rbuffer, *Gbuffer, *Bbuffer; /*入力用*/
  14. unsigned char *Rbuffer2, *Gbuffer2, *Bbuffer2; /*出力用*/
  15.  
  16. //Open CSV file
  17. if((fpi=fopen(argv[1],"r"))==NULL)
  18. {
  19. printf ("The file can't be opened. The program is exit.\n");
  20.  
  21. return 0;
  22. }
  23.  
  24. /*RGBを色平面に分解*/
  25. Rbuffer = (BYTE*)malloc( width*height ); /*メモリ確保*/
  26. Gbuffer = (BYTE*)malloc( width*height );
  27. Bbuffer = (BYTE*)malloc( width*height );
  28. RGB2Plane(buffer, Rbuffer, Gbuffer, Bbuffer, width, height);
  29.  
  30.  
  31. //Open VTK file for save
  32. if((fpo=fopen(argv[2],"wb"))==NULL)
  33. {
  34. printf("The file can't be opened. The program is exit.\n");
  35.  
  36. return 0;
  37. }
  38.  
  39.  
  40. //count how many lines
  41. /*
  42. while((c=fgetc(fpi))!=EOF)
  43. {
  44. if(c=='\n')
  45. newline_count++;
  46. }
  47. */
  48.  
  49. while(fscanf(fpi,"%d %f %f %f %d %d\n",id,x,y,z,ix,iy)!=EOF)
  50. {
  51. printf("%d %f %f %f %d %d\n",id,x,y,z,ix,iy);
  52.  
  53. fwrite(&id,sizeof(int), 1,fpo);
  54. fwrite(&x,sizeof(float),1,fpo);
  55. fwrite(&y,sizeof(float),1,fpo);
  56. fwrite(&z,sizeof(float),1,fpo);
  57. fwrite(&ix,sizeof(int),1,fpo);
  58. fwrite(&iy,sizeof(int),1,fpo);
  59.  
  60. }
  61.  
  62.  
  63. fclose(fpi);
  64. fclose(fpo);
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement