版主:
图形模式800X600下我想实现,当窗口弹出前保存窗口内容到XMS,而当窗口消失后恢复原先屏幕的内容。以下是程序,为什么实现不了呢?
char buf[800];//全局数组变量,每次取一行800个像素
unsigned short xms_handle;//XMS句柄
/**********************************************************/
/* 保存窗口内容到XMS
/**********************************************************/
void Save_Window_XMS(int x1,int y1,int x2,int y2)
{
int i,j;
unsigned short size,len;
unsigned long offset = 0;
char *pp;
size = (x2-x1+1)*(y2-y1+1)/1024 +1;
if (XMS_Size() < size)
puts("not enough XMS");
if ((xms_handle = XMS_Alloc(size)) == 0)//XMS申请空间成功
puts("XMS handle Error...\n");
for (i= y1; i<=y2;i++)
{
pp=buf;
for (j= x1; j<=x2;j++)
*pp++ = getpixel(j,i);//在屏幕上获取像素点
len = x2-x1+1;
Write_To_XMS(buf,len,xms_handle,offset);//缓冲区buf中存储的像素送至XMS
offset += len;
}
}
/**********************************************************/
/* 恢复XMS中的内容到屏幕
/**********************************************************/
void _Cdecl Restore_Window_XMS(int x1,int y1,int x2,int y2)
{
int i,j;
unsigned short len;
unsigned long offset = 0;
char *pp;
len = (x2-x1+1)
for (i= y1; i<=y2;i++)
{
Read_From_XMS(buf,len,xms_handle,offset);
offset += len;
pp=buf;
for (j= x1; j<=x2;j++)
putpixel(j,i,*pp++);
}
XMS_Free(xms_handle);
}