home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a014 / 1.ddi / CDBINC.EXE / TIF2.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-22  |  1.5 KB  |  78 lines

  1.  #include <stdio.h>
  2.  #include <conio.h>
  3.  #include <graphics.h>
  4.  #include <dos.h>
  5.  #include <alloc.h>
  6.  FILE *fp,*fopen();
  7.  int i,j,width,x,y;
  8.  int driver,mode;
  9.  
  10.  main()
  11.   {   char *defa_name,*in_name;
  12.       char ch;
  13.       void *buf;
  14.       int x,y;
  15.       unsigned long size;
  16.       x=0;
  17.       y=0;
  18.       clrscr();
  19.       defa_name="e:\\tc\\c\\x1.tif";
  20.       show_tif(defa_name,x,y);
  21.       size=imagesize(x,y,x+208,y+250);
  22.       buf=farmalloc(size);
  23.       do {
  24.      getimage(x,y,x+208,y+250,buf);
  25.      ch=getch();
  26.      if (ch=='6') x=x+10;
  27.      if (ch=='4') x=x-10;
  28.      if (ch=='8') y=y+10;
  29.      if (ch=='2') y=y-10;
  30.          putimage(x,y,buf,COPY_PUT);
  31.      }
  32.      while (ch!='q'&&ch!='Q');
  33.       restorecrtmode();
  34.   }
  35.  
  36.  show_tif(char *tif_file,int xbak,int ybak)
  37.  {   int x,y,widthh,widthl;
  38.      char ch;
  39.      x=xbak;
  40.      y=ybak;
  41.      driver=DETECT;
  42.      mode=2;
  43.      initgraph(&driver,&mode,"e:\\tc");
  44.      setcolor(LIGHTRED);
  45.      setbkcolor(BLUE);
  46.      textcolor(YELLOW);
  47.      fp=fopen(tif_file,"r");
  48.      if (fp==NULL)
  49.     { printf("Unable to open the file !\n");
  50.       fclose(fp);
  51.       return(-1);
  52.     };
  53.      fseek(fp,30,0);
  54.      widthl=getc(fp);
  55.      widthh=getc(fp);
  56.      width=widthh*256+widthl;
  57.      j=0xae;
  58.      fseek(fp,j,0);
  59.      while (!feof(fp))
  60.     {
  61.          ch=getc(fp);
  62.          for (i=0;i<=7;i++)
  63.          {
  64.          if ((ch&0x80)!=0) putpixel(x,y,LIGHTGREEN);
  65.          ch=ch<<1;
  66.          x++;
  67.          if (x>=xbak+width)
  68.             {
  69.             x=xbak;
  70.             y++;
  71.             };
  72.          };
  73.          j++;
  74.        };
  75.       fclose(fp);
  76.  }
  77.  
  78.