可编辑
r.x.ax=0x4f03;
int86(0x10,&r,&r);
return(r.x.bx);
}
drawbmp(int start_x,int start_y,char filename[])
{
char buffer[640];
int i,j,k,n,r,g,b,width,length;
long position;
FILE *fp;
if((fp=fopen(filename,"rb"))==NULL)
{
printf("Error! Can't open file!");
getch();
return;
}
fseek(fp,28,SEEK_SET);
fread(&i,2,1,fp);
if(i!=8) /*检查是否为256色位图*/
{
puts("Error!Can't find bitmap!");
fclose(fp);
getch();
exit(0);
}
fseek(fp,18,SEEK_SET);
fread(&width,4,1,fp);
fread(&length,4,1,fp);
if(firsttime)
{
fseek(fp,54,SEEK_SET);
for(i=0;i<256;i++) /*按照该图片的DAC色表设置色彩寄存器*/
{
b=fgetc(fp);g=fgetc(fp);r=fgetc(fp); /*获取R、G、B分量*/
outportb(0x3c8,i);
outportb(0x3c9,r>>2); /*右移是要转化为VGA的6位寄存器形式*/ outportb(0x3c9,g>>2);
outportb(0x3c9,b>>2);
fgetc(fp);
}
}
else
.