DOS真彩色模式下真彩色图像显示技术毕业(5)
2015-06-03 01:35
导读:struct SREGS sr; r.x.cx=mode; r.x.ax=0x4f01; sr.es =FP-SEG(modeinfo); r.x.di=FP-OFF(modeinfo); int86x(0x10,r,r,sr); Wingran =modeinfo.wingran; Line-bytes=modeinfo.bytesperscanline; Y-res =modeinfo.yre
struct SREGS sr;
r.x.cx=mode;
r.x.ax=0x4f01;
sr.es =FP-SEG(&modeinfo);
r.x.di=FP-OFF(&modeinfo);
int86x(0x10,&r,&r,&sr);
Wingran =modeinfo.wingran;
Line-bytes=modeinfo.bytesperscanline;
Y-res
=modeinfo.yres;
}
// 计算扫描线始址函数
void map(void)
{ register int i,j;
for(i=0; iaddr =(unsigned long)(i)*Line-bytes;
}
// 选择视频窗口对准页函数
void Selectpage(unsigned int page)
{ union REGS r;
if (page!=Curpage) {
r.x.bx=0;
r.x.dx=page*64L/Wingran;
r.x.ax=0x4f05;
int86(0x10,&r,&r);
Curpage=page;
}
}
// 16位高彩色仿真24位PCX真彩色图像显示函数
void highcolor(void)
{ register int i, j;
unsigned int red, green, blue;
unsigned int *word, *wordptr;
int n, m, k, cnt, total;
unsigned long segmet;
unsigned char *pic, *p0,*p1,*p2;
unsigned char page, picdata;
SetVesaMode(0x111);
map();
Selectpage(0);
n=min(480,height);
m=min(640,width);
word =(unsigned int *)malloc(2*m);
wordptr=word;
for (k=0; k<3; k++)
pic=(unsigned char *)malloc(m);
p0=pic; p1=pic; p2=pic;
fseek(fp,0x80L,SEEK-SET);
for(i=0; ipic=p0; pic=p1; pic=p2;
word=wordptr;
for (j=0;j<3;j++) {
total = 0;
while(total < m) {
cnt = 1;
picdata = fgetc(fp);
if(0xc0==(0xc0 & picdata)) {
cnt = 0x3f & picdata;
picdata = fgetc(fp);
for (k=0; k*pic++ =picdata;
}
else
*pic++ =picdata;
total+=cnt;
}
}
pic=p0; pic=p1; pic=p2;
for (j=0; jred = *pic++ >>3;
green= *pic++ >>2;
blue = *pic++ >>3;
red=red<<11; green=green<<5;
*word++ =red|green|blue;
}
word=wordptr;
for (j=0;j<2*(m-1);j+=2) {
(科教范文网 fw.nseac.com编辑发布)
segmet=addr+j;
page=segmet>>16;
if (segmet <= 65535L) {
poke(0xa000, addr+j, *word++ );
}
else {
Selectpage(page);
poke(0xa000, addr+j, *word++ );
}
}
}