Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***************************************************************************:::
- 3colors_to_1
- convert csv to raw
- read
- 2015/11/07
- made by Yoshiyuki Yamamoto
- ver1.1 2009/3/7
- *******************************************************************************/
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- int main(int argc,char *argv[])
- {
- /*****************************************************
- 1.Definition of Variables
- ******************************************************/
- FILE *fpr,*fpw; //file pointer for input&output file
- int color;//
- int dn1,dn2,dn3,dn4,dn5;
- unsigned char r,g,b;
- float x,y,z;
- /*****************************************************
- 2.command line arguments processing
- ******************************************************/
- if(argc!=3)
- {
- fprintf(stderr,"Usage: %s (1)input_org.txt\n(2)write_xyz FILENAME\n",argv[0]);
- exit(1);
- }
- printf("OPEN FILE NAME:%s\n",argv[1]);
- /**********************************************************************************
- **********************************************************************************
- 4. FILE OPEN + Binary File Input
- **********************************************************************************
- *************************************************************************************/
- // open input file
- if((fpr=fopen(argv[1],"r"))==NULL)
- {
- printf("ファイルのオープンに失敗しました。プログラムを終了します。\n");
- exit(1);
- }
- //write file
- if((fpw=fopen(argv[2],"wb"))==NULL)
- {
- fprintf(stderr,"DSM by GSI データファイル.raw\n");
- exit(1);
- }
- /*****************************************************
- データの読み取り書き込み
- ******************************************************/
- /* データ処理 */
- while (fscanf(fpr,"%f %f %f %d %d %d", &x,&y,&z,&r,&g,&b)!= EOF)
- {
- color=1000000*r+1000*g+b;
- fprintf(fpw,"%f %f %f %d\n",x,y,z,color);
- }
- /* ファイル・クローズ */
- fclose(fpr);
- fclose(fpw);
- }
Advertisement
Add Comment
Please, Sign In to add comment