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

  1.  #include <stdio.h>
  2.  #include <conio.h>
  3.  #include <graphics.h>
  4.  #include <dos.h>
  5.  FILE *fp,*fopen();
  6.  int i,j,x,y;
  7.  int driver,mode;
  8.  char ch;
  9.  int width;
  10.  
  11.  main()
  12.   {   char *tif_file;
  13.       int x,y;
  14.       x=0;
  15.       y=0;
  16.       tif_file="C:\\tc\\c\\x3.tif";
  17.       do {
  18.      show_tif(tif_file,x,y);
  19.      settextstyle(3,0,4);
  20.      outtextxy(10,1,"Q to end. Other key to show once more");
  21.      ch=getch(); }
  22.       while (ch!='q'&&ch!='Q');
  23.       restorecrtmode();
  24.   }
  25.  
  26.  show_tif(char *tif_file,int x,int y)
  27.  {   int xbak,widthh,widthl;
  28.      xbak=x;
  29.      driver=DETECT;
  30.      mode=2;
  31.      initgraph(&driver,&mode,"c:\\tc");
  32.      setcolor(LIGHTRED);
  33.      setbkcolor(WHITE);
  34.      textcolor(YELLOW);
  35.      fp=fopen(tif_file,"r");
  36.      if (fp==NULL)
  37.     { printf("Unable to open the file !\n");
  38.       getch();
  39.       exit(0);
  40.     };
  41.      fseek(fp,30,0);
  42.      widthl=getc(fp);
  43.      widthh=getc(fp);
  44.      width=widthh*256+widthl;
  45.      j=0xae;
  46.      fseek(fp,j,0);
  47.      while (!feof(fp))
  48.     {
  49.          ch=getc(fp);
  50.          for (i=0;i<=7;i++)
  51.          {
  52.          if ((ch&0x80)==0) putpixel(x,y,GREEN);
  53.          ch=ch<<1;
  54.          x++;
  55.          if (x>=xbak+width)
  56.             {
  57.             x=xbak;
  58.             y++;
  59.             };
  60.         };
  61.        };
  62.  
  63.  }
  64.  
  65.  
  66.