home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 3 / FREEWARE.BIN / towns_os / tvi / tvi_src.lzh / C / THEADCUT.C < prev   
C/C++ Source or Header  |  1990-11-13  |  1KB  |  50 lines

  1. /******************************************************************************
  2. $Header: theadcut.cv  1.2  90/11/13 20:37:34  Nam  Exp $
  3. *******************************************************************************/
  4. #include <stdio.h>
  5.  
  6. #define    BSIZE    (1024)
  7.  
  8. extern    void exit();
  9.  
  10. void main(argc,argv)
  11. int  argc;
  12. char *argv[];
  13. {
  14.     FILE    *fp1,*fp2;                /*** ファイル構造体 ***/
  15.     int        i,j;
  16.     char    buf[BSIZE+1];
  17.  
  18.     if (argc<2){
  19.         printf("Usage: theadcut.exp / Cutting Tiff-file's Header\n");
  20.         printf("       >run386 theadcut ???.tif ???.img\n");
  21.         exit(1);
  22.     }
  23.     fp1=fopen(argv[0],"rb");                /*** ファイルをOpen ***/
  24.     if (fp1==NULL) {
  25.         printf("tvi_rec.tifをopenできません\n");
  26.         exit(1);
  27.     }
  28.     if (fseek(fp1,0x0200,SEEK_CUR)!=0){
  29.         printf("tvi_rec.tifのヘッダがありません\n");
  30.         fclose(fp1);
  31.         exit(1);
  32.     }
  33.     fp2=fopen(argv[1],"wb");                /*** ファイルをOpen ***/
  34.     if (fp2==NULL) {
  35.         printf("tvi_rec.imgをopenできません\n");
  36.         fclose(fp1);
  37.         exit(1);
  38.     }
  39.     while (fp1!=NULL) {
  40.         i=fread(&buf,1,BSIZE,fp1);
  41.         j=fwrite(&buf,1,i,fp2);
  42.         if ((i<1)||(i!=j)){
  43.             fclose(fp1);
  44.             fclose(fp2);
  45.             break;
  46.         }
  47.     }
  48.     exit();
  49. }
  50.