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 *fpi1,*fpi2,*fpo;
- int id,ix,iy,widthe,height;
- float x,y,z;
- unsigned char dn;
- unsigned char *buffer; /*入力画像用メモリのポインタ*/
- //Open CSV file
- if((fpi1=fopen(argv[1],"r"))==NULL)
- {
- printf ("The file can't be opened. The program is exit.\n");
- return 0;
- }
- if((fpi2=fopen(argv[2],"rb"))==NULL)
- {
- printf ("The file can't be opened. The program is exit.\n");
- return 0;
- }
- /*RGBを色平面に分解
- Rbuffer = (unsigned char*)malloc( width*height );
- Gbuffer = (unsigned char*)malloc( width*height );
- Bbuffer = (unsigned char*)malloc( width*height );
- */
- buffer = (unsigned char*)malloc(width*height*3);
- fread((unsigned char*)buffer,sizeof(char),width*height*3,fpi2);
- //Open VTK file for save
- if((fpo=fopen(argv[3],"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(fpi1,"%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);
- buffer[iy*width+ix]=127;
- buffer[(iy*width+ix)+width*height]=127;
- buffer[(iy*width+ix)+width*height*2]=127;
- }
- for(i=0r;i<height*3;i++)
- {
- for(j=0;j<width;j++)
- {
- dn=buffer[i*width+j];
- fwrite(&dn,sizeof(char),1,fpo);
- }
- }
- fclose(fpi1);
- fclose(fpi2);
- fclose(fpo);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement