home *** CD-ROM | disk | FTP | other *** search
/ CD-X 1 / cdx_01.iso / demodisc / basq / source / mystic / intro / scpix.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  1.1 KB  |  53 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <io.h>
  4. #include <fcntl.h>
  5. #include <sys\stat.h>
  6. #include <d:\poweru\cache.h>
  7.  
  8. void main(int parnum,char *pars[])
  9.     {
  10.     int                        pointnum=0,
  11.                                 infileh,
  12.                                 scikv,
  13.                                 scikh;
  14.     FILE                    *outfile;
  15.     unsigned char    pixel;
  16.  
  17.     if(parnum<2)
  18.         {
  19.         printf("Too few parameters!!\n\n");
  20.         exit(EXIT_FAILURE);
  21.         }
  22.     if((infileh=open(pars[1],O_RDONLY|O_BINARY))==-1)
  23.         {
  24.         printf("Bad filename!!\n\n");
  25.         exit(EXIT_FAILURE);
  26.         }
  27.     if(!(outfile=fopen("datas.db","wb")))
  28.         {
  29.         printf("Output file creation error!!\n\n");
  30.         exit(EXIT_FAILURE);
  31.         }
  32.     fprintf(outfile,"datas");
  33.     readablecache cachein(infileh);
  34.     for(scikv=0;scikv<200;scikv++)
  35.         {
  36.         for(scikh=0;scikh<320;scikh++)
  37.             {
  38.             pixel=cachein.readitem();
  39.             if(pixel==255)
  40.                 {
  41.                 pointnum++;
  42.                 fprintf(outfile,"\tdw\t%i,%i,0\t\t;%i%c%c",scikh-159,0-(scikv-99),pointnum,0x0d,0x0a);
  43.                 printf("\tdw\t%i,%i,0\t\t;%i%c%c",scikh-159,0-(scikv-99),pointnum,0x0d,0x0a);
  44.                 }
  45.             }
  46.         }
  47.     cachein.~readablecache();
  48.     close(infileh);
  49.     fclose(outfile);
  50.     printf("%i points.\n\n",pointnum);
  51.     exit(EXIT_SUCCESS);
  52.     }
  53.