#include <dos.h>
#include <stdio.h>
#include <fcntl.h>
#include <graphics.h>
typedef struct
{
unsigned char b;
unsigned char g;
unsigned char r;
}
rgb16M;
int GRPAH_MAXX;
int keep_page=0;
int huge Return_SVGA64K(void)
{
return(3);
}
void Init64k()
{
int gd=DETECT,gm=0;
installuserdriver("Svga64K", Return_SVGA64K);
initgraph(&gd, &gm, "");
GRPAH_MAXX=getmaxx()+1;
}
int putpoint(int x, int y, rgb16M color)
{
int page;
page = (int)((y*(long)GRPAH_MAXX +x) >> 15);
if(keep_page!=page)
{
_BX = 0;
_DX =page;
_AX = 0x4f05;
__int__(0x10);
keep_page=page;
}
setrgbpalette(1026, color.r >> 3, color.g >> 2, color.b >> 3);
putpixel(x, y, 0);
}
int Draw_64k(int fp ,long jump ,int draw_x ,int draw_y ,int width_x,int height_y ,int lucency)
{
int i,j;
rgb16M *buffer;
buffer = (rgb16M *)malloc(width_x*sizeof(rgb16M));
for(j = height_y-1; j >= 0; j--)
{
read(fp, buffer, width_x*sizeof(rgb16M));
for(i = 0; i < width_x; i++)
if(buffer[i].b+buffer[i].g+buffer[i].r+lucency) putpoint(draw_x + i, draw_y + j, buffer[i]);
lseek(fp, jump, SEEK_CUR);
}
free(buffer);
}
int Draw_64k_View(char *Filename,int x0,int y0,int lucency )
{
int WIDTH, HEIGHT, fp;
long fix;
if((fp = open(Filename, O_RDONLY | O_BINARY)) == -1)
{
printf("Can't find File ""%s"".",Filename);
getch();
return 1;
}
WIDTH=GetWidth(fp);
HEIGHT=GetHeight(fp);
fix =(long)(WIDTH % 4);
lseek(fp, 54l+fix+(WIDTH%4==2), SEEK_SET);
Draw_64k(fp,fix,x0,y0,WIDTH,HEIGHT,lucency);
close(fp);
return 0;
}
int GetWidth(int fp)
{
long WIDTH;
lseek(fp, 18l, SEEK_SET);
read(fp, &WIDTH, 4);
return WIDTH;
}
int GetHeight( int fp)
{
long HEIGHT;
lseek(fp, 22l, SEEK_SET);
read(fp, &HEIGHT, 4);
return HEIGHT;
}
main()
{
Init64k();
Draw_64k_View("sssssss.bmp",0,0,0);getch();
Draw_64k_View("胜利.bmp",0,0,0);getch();
}
这是我写的显示程序
是不是其他的地方出的错啊
还是文件格式就是我说的那样???