资源描述:
《vga16色模式下的图像漫游论文》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、VGA16色模式下的图像漫游论文.freele存放漫游图文件;(xleft,ytop)在屏幕上窗口左上角坐标;(xright,ybuttom)在屏幕上窗口左上角坐标;number图号(0-nxy×nxy-1)nxynxy*nxy拼图*/voidsavee,intxleft,intytop,intxright,intybuttom,intnumber,intnxy){FILE*fp;inti,p,offset,offset1;charfar*base;-ytop+1;fp=fopen(fname,"rb+");offset=(Long)(number-number%nxy)*(long)ber%
2、nxy)*(long)e存放漫游图文件名;(xleft,ytop)在fname中虚拟窗口左上角坐标;(xright,ybuttom)在fname中虚拟窗口右下角坐标;nxynxy*nxy拼图*/voidLoade,intxo,inty0,intxleft,intytop,intxright,intybuttom,intnxy){FILE*fp;registerintj,i,n=8,e,"rb");-ytop+1;for(i=3;ii--){outportb(INDEXREG1,5);outportb(VALREG1,0);outportb(INDEXREG2,2);outportb(VALRE
3、G2,n);base=(charfar*)VGABASE+(long)y0×80L+(long)(x0/8);offset=(long)(i*nxy*nxy)*(long)(YP2-YP1+1)*(long)((XP2-XP1+1)/8)+(long)(xleft/8)+(long)(ytop*nxy)*(long)((XP2-XP1+1)/8);for(j=0;jheight;j++){fseek(fp,offset,SEEK_SET);fread(base,1,)定义漫游窗口;dy向上漫游(以象素为单位);dy向下漫游(以象素为单位)*/voidscroll-y(intxleft,inty
4、top,intxright,intybuttom,intdy){intp;registeri,j;charfar*base,far*tbase;longoffset,toffset;outportb(INDEXERG1,5);outportb(VALREG1,1);-ytop+1;if(dy0){base=(charfar*)VGABASE+(long)(ytop*80)+(long)(xleft/8);tbase=base;toffset=(long)dy*80L;temp=height+dy;/*ovetoupdy0*/for(i=0;itemp;i++){for(j=0;j*80)+(l
5、ong)(xleft/8);tbase=base;toffset=(long)dy*80L;temp=height-dy;/*dy0*/for(i=0;itemp;i++){for(j=0;j)定义漫游窗口;dx0向左漫游(以8个象素为单位);dx0向右漫游(以8个象素为单位)*/voidscroll-x(intxleft,intytop,intxright,intybuttom,intdx){intp;registeri,j;charfar*base,far*tbase;longoffset;outportb(INDEXREG1,5);outportb(VALREG1,1);-ytop+1;
6、if(dx0){base=(charfar*)VGABASE+(long)(ytop*80)+(long)(xleft/8);tbase=base;temp=ovetoleftdx0*/for(i=0;iheight;i++){for(j=0;jtemp;j++){*base=*(base-dx);base++;}tbase=tbase+80L;base=tbase;}}else{base=(charfar*)VGABASE+(long)(ytop*80)+(long)((xright-7)/8;tbase=base;temp=p;j++){*base=*(base-dx);base--;}t
7、base=tbase+80L;base=tbase;}}outportb(INDEXREG1,0);}四、示例示例exm1.cpp中,首先在虚拟的大幅漫游图上画一个贯穿整个漫游图的“×”,然后按2×2图幅存入ZOOM.SCR文件。在示例exm2.cpp中,通过方向键控制图像漫游。程序1exm1.cpp#includestdio.h#includestdlib.h#includeconio.h#in