C语言函数大全(i开头)
函数名:imagesize
函数:返回保存位映像所需的字节数
用法:无符号远映像大小(int left,int top,int right,int bottom);
程序示例:
# include
# include
# include
# define arrow _ size 10
void draw _ arrow(int x,int
int main(void)
{
/*请求自动检测*/
int gdriver = DETECT,gmode,errorcode
void * arrow;
int x,y,maxx
无符号整型大小;
/*初始化图形和局部变量*/
initgraph(&gdriver,&gmode," ");
/*读取初始化结果*/
error code = graph result();
if(错误代码!= grOk) /*出现错误*/
{
printf("图形错误:%s\n ",grapherrormsg(error code));
printf("按任意键暂停:");
getch();
退出(1);/*以错误代码*/
}
maxx = getmaxx()终止;
x = 0;
y = get maxy()/2;
/*绘制要抓取的图像*/
draw_arrow(x,y);
/*计算图像的大小*/
size = imagesize(x,y-ARROW_SIZE,x+(4*ARROW_SIZE),y+ARROW _ SIZE);
/*分配内存来保存图像*/
arrow = malloc(size);
/*抓取图像*/
getimage(x,y-ARROW_SIZE,x+(4*ARROW_SIZE),y+ARROW_SIZE,ARROW);
/*重复,直到按下一个键为止。kbhit())
{
/*擦除旧图像*/
putimage(x,y-ARROW_SIZE,ARROW,XOR _ PUT);
x+= ARROW _ SIZE;
if(x > = maxx)
x = 0;
/* plot new image */
putimage(x,y-ARROW_SIZE,ARROW,XOR _ PUT);
}
/*清理*/
免费(箭头);
closegraph();
返回0;
}
void draw _ arrow(int x,int y)
{
/*在屏幕上画一个箭头*/
moveto(x,y);
linerel(4*ARROW_SIZE,0);
linerel(-2*ARROW_SIZE,-1 * ARROW _ SIZE);
linerel(0,2 * ARROW _ SIZE);
linerel(2*ARROW_SIZE,-1 * ARROW _ SIZE);
}
0条评论