云端号是什么:c语言中getimage()的作用及用法

来源:百度文库 编辑:高考问答 时间:2024/05/06 02:23:45

getimage() 保存图像函数
功能: 函数getimage()保存左上角与右下角所定义的屏幕上像素图形到指定的内存区域。
用法: 该函数调用方式为void getimage(int left,int top,int right,int bottom,void *buf);
说明: 函数中参数(left,top)为要保存的图像屏幕的左上角,(right,bottom)为其右下角,buf指向保存图像的内存地址。调用getimage()保存屏幕图像,可用imagesize()函数确定保存图像所需字节数,再用malloc()函数分配存储图像的内存(内存分配必须小于64KB),还可以用下面函数putimage()输出getimage()保存的屏幕图像。
这个函数对应的头文件为graphics.h
返回值: 无
例: 把带有两对角线的矩形拷贝到屏幕其它位置上:
#include<garphics.h>
#include<stdlib.h>
#include<conio.h>
void main()
{
int driver,mode;
unsigned size;
void *buf;
driver=DETECT;
mode=0;
initgraph(&driver,&mode,"");
sector(15);
rectangle(20,20,200,200);
setcolor(RED);
line(20,20,200,200);
setcolor(GREEN);
line(20,200,200,20);
getch();
size=imagesize(20,20,200,200);
if(size!=-1){
buf=malloc(size);
if(buf){
getimage(20,20,200,200,buf);
putimage(100,100,buf,COPy_PUT);
putimage(300,50,buf,COPy_PUT);
}
}
outtext("press a key");
getch();
restorecrtmode()