Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1.         pngo.scale_wh(50, 20);
  2.  
  3.  
  4.         fcode data;
  5.         data.out[0] = tolower(file[12]);
  6.         data.out[1] = tolower(file[13]);
  7.         data.out[2] = tolower(file[14]);
  8.  
  9.  
  10.         char newbin[50];
  11.         sprintf( newbin, "%ccbox.dat", (ang>0? 'u' : 'l'), out);
  12.  
  13.         FILE * fp = fopen( newbin, "a" );
  14.         if(fp == NULL) {
  15.             perror("failed to open box.dat");
  16.             return 0;
  17.         }
  18.  
  19.         double halfwhite = white/2;
  20.         for(int y = 0; y < pngo.getheight(); y++)
  21.         for(int x = 0; x < pngo.getwidth(); x++ ) {
  22.                 data.in[y][x] = (double)(pngo.read(x+1,y+1) - halfwhite)/ (halfwhite+1);
  23.                 fprintf( fp, "%0.1f ", data.in[y][x] );
  24.         }
  25.  
  26.         fprintf( fp, "\n" );
  27.  
  28.         char s[18] = { '1','2','3','4','5','7','9','a','b','c','h','j','k','m','r','w','x','y' };
  29.  
  30.         for(int j = 0; j < 3; j++ )
  31.         for(int i = 0; i < 18; i++  )
  32.             if( s[i] == data.out[j] )
  33.                fprintf(fp, "%0.1f ", 1.0 );
  34.             else
  35.                fprintf(fp, "%0.1f ", -1.0 );
  36.  
  37.         fprintf( fp, "\n" );
  38.  
  39.         if( fclose(fp) )
  40.             printf("fclose(fp) failed.\n" );
  41.  
  42.         cout << "Done with " << (char)tolower(file[12]) << (char)tolower(file[13]) << (char)tolower(file[14]) << endl;
  43.         pngo.close();
  44.  
  45.         return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement