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,i,j,width,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;
- }
- width = atoi(argv[4]); printf("W = %d,", width);
- height = atoi(argv[5]); printf("H = %d\n", height);
- /*RGBを色平面に分解
- Rbuffer = (unsigned char*)malloc( width*height );
- Gbuffer = (unsigned char*)malloc( width*height );
- Bbuffer = (unsigned char*)malloc( width*height );
- */
- printf("check0\n");
- buffer = (unsigned char*)malloc(width*height*3);
- printf("check1\n");
- fread((unsigned char*)buffer,sizeof(char),width*height*3,fpi2);
- printf("check2\n");
- //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++;
- }
- */
- printf("check3\n");
- while(fscanf(fpi1,"%f %f %f %d %d",&x,&y,&z,&ix,&iy)!=EOF)
- {
- //printf("%f %f %f %d %d\n",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;
- buffer[3*(iy*width+ix)]=127;
- buffer[3*(iy*width+ix)+1]=127;
- buffer[3*(iy*width+ix)+2]=127;
- }
- for(i=0;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