XMS申请内存已解决。窗口保存及恢复,为什么窗口最后一列无法恢复呢?以下为源程序
int POPUP_x1, POPUP_x2,POPUP_y1,POPUP_y1;//窗口坐标(以像素素为单位)
char XMSBuffer[800];
/*-----------------------------------------------------------
//保存窗口映像到XMS
-----------------------------------------------------------*/
void _Cdecl Save_Image_XMS(void)
{
int i, j;
unsigned int size;
long long_size;
unsigned long offset = 0;
char *pp;
long_size = ((long)POPUP_x2-(long)POPUP_x1+1)*
((long)POPUP_y2-(long)POPUP_y1+1);
long_size = long_size/1024+1;
size = long_size; //被窗口遮盖区域需要的KB数
if (XMS_Size() > size) // 如果可XMS可用空间大于窗口区域所需的空间
{
if ((xms_window_handle = XMS_Alloc(size)) != 0) // 申请相应空间
{
size = POPUP_x2 - POPUP_x1;
for (i = POPUP_y1 ; i <= POPUP_y2 ; i++)//窗口列坐标循环
{
pp = XMSBuffer; // 缓冲区指针指向缓冲区
for (j = POPUP_x1 ; j <= POPUP_x2 ; j++) // 窗口行坐标循环
*pp++ = getpixel(j,i);
Write_To_XMS(XMSBuffer,size,xms_window_handle,offset);//读一行后送到XMS
offset += size;
}
}
}
/*-----------------------------------------------------------
//恢复窗口映像从XMS
-----------------------------------------------------------*/
void _Cdecl Restore_Image_XMS(void)
{
int i, j;
unsigned short size;
unsigned long offset = 0;
char *pp;
for (i = POPUP_y1 ; i <= POPUP_y2 ; i++)
{
size = POPUP_x2 - POPUP_x1;
Read_From_XMS(XMSBuffer,size,xms_window_handle,offset);//从XMS读一行屏幕内容到缓冲区XMSBuffer中。
offset += size;
pp = XMSBuffer;
for (j = POPUP_x1 ; j <= POPUP_x2 ; j++)
putpixel(j,i,*pp++);
}
XMS_Free(xms_window_handle);//释放
}