Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main(int argc, char *argv[])
- {
- //Decralation of variables
- FILE *fpi,*fpo;
- int id,ix,iy;
- float x,y,z;
- char nan[4];
- unsigned char *buffer; /*入力画像用メモリのポインタ*/
- unsigned char *buffer2; /*出力画像用メモリのポインタ*/
- unsigned char *Rbuffer, *Gbuffer, *Bbuffer; /*入力用*/
- unsigned char *Rbuffer2, *Gbuffer2, *Bbuffer2; /*出力用*/
- //Open CSV file
- if((fpi=fopen(argv[1],"r"))==NULL)
- {
- printf ("The file can't be opened. The program is exit.\n");
- return 0;
- }
- /*RGBを色平面に分解*/
- Rbuffer = (BYTE*)malloc( width*height ); /*メモリ確保*/
- Gbuffer = (BYTE*)malloc( width*height );
- Bbuffer = (BYTE*)malloc( width*height );
- RGB2Plane(buffer, Rbuffer, Gbuffer, Bbuffer, width, height);
- //Open VTK file for save
- if((fpo=fopen(argv[2],"wb"))==NULL)
- {
- printf("The file can't be opened. The program is exit.\n");
- return 0;
- }
- //count how many lines
- /*
- while((c=fgetc(fpi))!=EOF)
- {
- if(c=='\n')
- newline_count++;
- }
- */
- while(fscanf(fpi,"%d %f %f %f %d %d\n",id,x,y,z,ix,iy)!=EOF)
- {
- printf("%d %f %f %f %d %d\n",id,x,y,z,ix,iy);
- fwrite(&id,sizeof(int), 1,fpo);
- fwrite(&x,sizeof(float),1,fpo);
- fwrite(&y,sizeof(float),1,fpo);
- fwrite(&z,sizeof(float),1,fpo);
- fwrite(&ix,sizeof(int),1,fpo);
- fwrite(&iy,sizeof(int),1,fpo);
- }
- fclose(fpi);
- fclose(fpo);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement