home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <conio.h>
- #include <graphics.h>
- #include <dos.h>
- #include <alloc.h>
- FILE *fp,*fopen();
- int i,j,width,x,y;
- int driver,mode;
-
- main()
- { char *defa_name,*in_name;
- char ch;
- void *buf;
- int x,y;
- unsigned long size;
- x=0;
- y=0;
- clrscr();
- defa_name="e:\\tc\\c\\x1.tif";
- show_tif(defa_name,x,y);
- size=imagesize(x,y,x+208,y+250);
- buf=farmalloc(size);
- do {
- getimage(x,y,x+208,y+250,buf);
- ch=getch();
- if (ch=='6') x=x+10;
- if (ch=='4') x=x-10;
- if (ch=='8') y=y+10;
- if (ch=='2') y=y-10;
- putimage(x,y,buf,COPY_PUT);
- }
- while (ch!='q'&&ch!='Q');
- restorecrtmode();
- }
-
- show_tif(char *tif_file,int xbak,int ybak)
- { int x,y,widthh,widthl;
- char ch;
- x=xbak;
- y=ybak;
- driver=DETECT;
- mode=2;
- initgraph(&driver,&mode,"e:\\tc");
- setcolor(LIGHTRED);
- setbkcolor(BLUE);
- textcolor(YELLOW);
- fp=fopen(tif_file,"r");
- if (fp==NULL)
- { printf("Unable to open the file !\n");
- fclose(fp);
- return(-1);
- };
- fseek(fp,30,0);
- widthl=getc(fp);
- widthh=getc(fp);
- width=widthh*256+widthl;
- j=0xae;
- fseek(fp,j,0);
- while (!feof(fp))
- {
- ch=getc(fp);
- for (i=0;i<=7;i++)
- {
- if ((ch&0x80)!=0) putpixel(x,y,LIGHTGREEN);
- ch=ch<<1;
- x++;
- if (x>=xbak+width)
- {
- x=xbak;
- y++;
- };
- };
- j++;
- };
- fclose(fp);
- }
-