該樓層疑似違規已被系統折疊?隱藏此樓查看此樓
/*?Svga64k.bgi?測試文件?*/
#include?"graphics.h"
#include?"Svga256.h"
#include?"stdio.h"
#include?"fcntl.h"
#include?"malloc.h"
#include?"io.h"
int?huge?Return_SVGA256(void)
{
return(SVGA320x200x256);?/*?返回各種分辨率的對應編號?0~6?宏定義參見?Svga256.h?*/
}
void?main()
{int?width,height,i=DETECT,j=0,x0,y0,fp,x_x;
unsigned?char?fix,*buffer,pix24b[4];
DacPalette256?dac256;
installuserdriver("Svga256",Return_SVGA256);/*?對于svga256必需執行該函數以安裝BGI驅動?*/
initgraph(&i,&j,"");/*?執行TC默認的BGI初始化函數?*/
for(x_x=0;x_x<76;x_x++){
if(x_x=1)
{
if((fp=open("xy_256.bmp",O_RDONLY|O_BINARY))==-1)
{
puts("Can't?find?file?""xy_256.bmp"".");
exit(1);
}
}
else
if(x_x=2){
if((fp=open("xy_2561.bmp",O_RDONLY|O_BINARY))==-1)
{
puts("Can't?find?file?""xy_256.bmp"".");
exit(1);
}
}
else
if(x_x=3){
if((fp=open("xy_2562.bmp",O_RDONLY|O_BINARY))==-1)
{
puts("Can't?find?file?""xy_256.bmp"".");
exit(1);
}
}
else
if(x_x=4){
if((fp=open("xy_2563.bmp",O_RDONLY|O_BINARY))==-1)
{
puts("Can't?find?file?""xy_256.bmp"".");
exit(1);
}
}
else
if(x_x=5){
if((fp=open("xy_2564.bmp",O_RDONLY|O_BINARY))==-1)
{
puts("Can't?find?file?""xy_256.bmp"".");
exit(1);
}
}
else
if(x_x=6){
if((fp=open("xy_2565.bmp",O_RDONLY|O_BINARY))==-1)
{
puts("Can't?find?file?""xy_256.bmp"".");
exit(1);
}
}
lseek(fp,18,SEEK_SET);
read(fp,&width,4);
read(fp,&height,4);
fix=(width%4)?(4-width%4):0;
x0=(320-width)/2;y0=(200-height)/2;
lseek(fp,54,SEEK_SET);
for(i=0;i<256;i++)?/*?按照該圖片的DAC色表設置色彩寄存器?*/
{read(fp,pix24b,4);?/*?讀取DAC分量信息?*/
dac256[i][0]=pix24b[2]>>2;dac256[i][1]=pix24b[1]>>2;dac256[i][2]=pix24b[0]>>2;?/*?設置調色板?*/
}
setvgapalette256(&dac256);?/*?應用調色板,?定義參見?Svga256.h?*/
buffer=(unsigned?char?*)malloc(width);
for(j=height-1;j>=0;j--)
{read(fp,buffer,width);
lseek(fp,fix,SEEK_CUR);
for(i=0;i
putpixel(x0+i,y0+j,buffer[i]);
}
free(buffer);
close(fp);
}
getch();
closegraph();
}