Advertisement
Kojima0502

textbinary OsakaWan

Oct 3rd, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.59 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(int argc,char*argv[])
  6. {
  7.     FILE *fpi,*fpo;
  8.     int i,j,height,width,r_height;
  9.     int k,l;
  10.     int a,r;
  11.     float data;
  12.     float *file3;
  13.     char line[9];
  14.     if(argc!=6)
  15.     {
  16.         fprintf(stderr,"Usage: %s 5m_mesh_data.lem,5m_mesh_data.raw\n",argv[0]);
  17.         exit(1);
  18.     }
  19.     printf("OPEN FILE NAME:%s\n",argv[1]);
  20.    
  21.     if((fpi=fopen(argv[1],"r"))==NULL)
  22.     {
  23.         fprintf(stderr,"5mïWçÇÉfÅ[É^ÉtÉ@ÉCÉãñº.lem\n");
  24.         exit(1);
  25.     }
  26.    
  27.     if((fpo=fopen(argv[2],"wb"))==NULL)
  28.     {
  29.         fprintf(stderr,"5mïWçÇÉfÅ[É^ÉtÉ@ÉCÉã.raw\n");
  30.         exit(1);
  31.     }
  32.    
  33.     height=atoi(argv[3]);
  34.     r=atoi(argv[5]);
  35.     a=r/10;
  36.     width=atoi(argv[4]);
  37.     r_height=height*width/10;
  38.    
  39.     file3= (float *)malloc(width*height*sizeof(float));
  40.    
  41.     for(i=0;i<r_height;i++)
  42.     {
  43.         fseek(fpi,i*82,SEEK_SET);
  44.        
  45.         for (j=0;j<10;j++)
  46.         {
  47.             fseek(fpi,8*j+i*82,SEEK_SET);
  48.             fgets(line, 9, fpi);
  49.             data=atof(line);
  50.             // printf("%f\n",data);
  51.             file3[i*10+j]=data;
  52.         }
  53.     }
  54.    
  55.    
  56.    
  57.     for(i=0;i<height*a;i++)
  58.     {
  59.        
  60.        
  61.         for(j=0;j<width*a;j++)
  62.         {
  63.             k=i/a;
  64.             l=j/a;
  65.             data=file3[k*width+l];
  66.            
  67.            
  68.             // printf("%f\n",data);
  69.             fwrite(&data,sizeof(float),1,fpo);
  70.         }
  71.     }
  72.    
  73.    
  74.     free(file3);
  75.     fclose(fpi);
  76.     fclose(fpo);
  77.    
  78.     return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement