标题:窗口弹出前保存窗口内容到XMS
取消只看楼主
beyondabcd
Rank: 1
等 级:新手上路
帖 子:112
专家分:0
注 册:2007-5-19
 问题点数:0 回复次数:2 
窗口弹出前保存窗口内容到XMS

当窗口弹出前保存窗口内容到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;
}
}
--------------------------------------------------------------------------------------------------------
原程序是800X600模式的,用除1024,我想用640 X 480的模式,应该除什么数呀?

搜索更多相关主题的帖子: 窗口内容 XMS int unsigned short 
2007-09-18 15:46
beyondabcd
Rank: 1
等 级:新手上路
帖 子:112
专家分:0
注 册:2007-5-19
得分:0 
不好意思,我问一个很莱的问题
2007-09-19 14:49
beyondabcd
Rank: 1
等 级:新手上路
帖 子:112
专家分:0
注 册:2007-5-19
得分:0 

#include "graphics.h"
#include<dos.h>

#include<conio.h>

#include "stdio.h"
#include "fcntl.h"
#include "malloc.h"
#include "io.h"
#include "showbmp.c"
#include "rsvga256.h"

typedef unsigned int XMS_HANDLE;
XMS_HANDLE xms_handle; /* 伪指针 */
XMS_HANDLE xms_save_restore_handle; /* 伪指针 */

typedef struct emm {
unsigned int length;
unsigned source_handle;
unsigned long source_offset;
unsigned dest_handle;
unsigned long dest_offset;
} xmm;
xmm xms;

int far(* XMS_Function)( );
int xms_installed( )
{
_AX=0x4300;
geninterrupt(0x2f);
if(_AL==0x80)
{
_AX=0x4310;
geninterrupt(0x2f);
XMS_Function=MK_FP(_ES,_BX);
return(1);
}
else
{
printf("XMS is not installed\n!");
return(0);
}
}

int test_xms(unsigned int size)
{
_AH=8;
XMS_Function( );
if(_AX<size)
{
printf("No enough XMS to be used!\n");
return(0);
}
else
return(1);
}

unsigned int alloc_xms(unsigned int size)
{
_DX=size;
_AH=9;
XMS_Function( );
if(_AX!=1)
{
printf("XMS allocation is error\n");
return(0);
}
else
return(_DX);
}


int move_xms(xms)
{
_DS=FP_SEG(xms);
_SI=FP_OFF(xms);
_AH=0x0b;
XMS_Function( );

if(_AX!=1)
{
printf("XMS move error! %d\n",_BL);
return(0);
}
else
return(1);
}

void free_xms(unsigned int handle)
{
_DX=handle;
_AH=0x0a;
XMS_Function( );
}


/*----------------------------------------------------------- */
/* 从常规内存缓冲区buf装载到扩充内存 */
/*-----------------------------------------------------------*/


void Write_To_XMS(char *buf, unsigned int size,unsigned handle,unsigned long offset)
{
xms.length=size;
xms.source_handle = 0;
xms.source_offset = FP_SEG((void far *)buf);
xms.source_offset <<= 16;
xms.source_offset += FP_OFF((void far *)buf);
xms.dest_handle = handle;
xms.dest_offset = offset;
move_xms(&xms);
}


/*----------------------------------------------------------- */
/* 从扩充内存中读取信息到常规内存缓冲区buf */
/*-----------------------------------------------------------*/
void Read_From_XMS(char *buf,unsigned int size,unsigned handle,unsigned long offset)
{
xms.length = size;
xms.source_handle = handle;
xms.source_offset = offset;
xms.dest_handle = 0;
xms.dest_offset = FP_SEG((void far *)buf);
xms.dest_offset <<= 16;
xms.dest_offset += FP_OFF((void far *)buf);
move_xms(&xms);
}


char sssbuf[400];
void Save_Image_XMS(int POPUP_x1,int POPUP_x2,int POPUP_y1,int POPUP_y2 )
{
int i,j;
unsigned int size;
unsigned long offset = 0;
char *pp;

size = (POPUP_x2-POPUP_x1+1)*(POPUP_y2-POPUP_y1+1)/1024+1;

if (test_xms(size)==0)
puts("not enough XMS"); printf("%d",test_xms(size));getch();
if ((xms_save_restore_handle = alloc_xms(size)) == 0)
puts("XMS handle Error...\n");
for (i= POPUP_y1; i<=POPUP_y2;i++)
{
size = POPUP_x2-POPUP_x1; printf("%d",size);
pp = sssbuf;
for (j= POPUP_x1; j<=POPUP_x2;j++)
*pp++ = getpixel(j,i);
Write_To_XMS(sssbuf,size,xms_save_restore_handle,offset);
offset += size;
}
}


void Restore_Image_XMS(int POPUP_x1,int POPUP_x2,int POPUP_y1,int POPUP_y2)
{
int i,j;
unsigned short size;
unsigned long offset = 0;
char *pp;

size = POPUP_x2-POPUP_x1;
for (i= POPUP_y1; i<=POPUP_y2;i++)
{
Read_From_XMS(sssbuf,size,xms_save_restore_handle,offset);
offset += size;
pp = sssbuf;
for (j= POPUP_x1; j<=POPUP_x2;j++)
putpixel(j,i,*pp++);/* sssbuf[j-POPUP_x1]); */
}
free_xms(xms_save_restore_handle);
}


int huge rReturn_SVGA256(void)
{
return(SVGA640x480x256);
}

void main()
{ int iii=DETECT, jjj=0;

installuserdriver("Svga256", rReturn_SVGA256); /* 对于svga256必需执行该函数以安装BGI驱动 */
initgraph(&iii, &jjj, "");
printf("%d",xms_installed( ));getch();
show_bmp("main.bmp",0,0); getch();
Save_Image_XMS(50,110,50,100 );
getch();
show_bmp("bell.bmp",40,40);
getch();
Restore_Image_XMS(50,110,50,100);
getch();
closegraph();
}

程序走到黄体字时,就走不了,大家帮忙看看



MTSXSJ0Y.rar (15.61 KB) 窗口弹出前保存窗口内容到XMS


2007-09-19 15:10



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-170943-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.773492 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved