imagesize

基本介紹

  • 中文名:imagesize
  • 外文名: imagesize
  • 功 能:返回保存點陣圖像所需的位元組數
基本信息,程式舉例,

基本信息

函式名: imagesize
功 能: 返回保存點陣圖像所需的位元組數
用 法: unsigned far imagesize(int left, int top, int right, int bottom);
頭檔案: conio.h

程式舉例

#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <graphics.h>
#define ARROW_SIZE 10
void draw_arrow(int x,int y);
int main(void)
{
int gdriver,gmode,errorcode;
int x,y,maxx;
int *arrow;
unsigned size;
/* initialize graphics and local variables */ //初始化圖形和局部變數
gdriver=DETECT;
initgraph(&gdriver,&gmode,"");
/* read the result of initialization */ //讀取初始化的結果
errorcode=graphresult();
if(errorcode!=grOk) /* an error occurred */
{
printf("Graphics error: %s\n",grapherrormsg(errorcode));
getch();
exit(1); /* terminate with an error code */
}
maxx=getmaxx();
x=0;
y=getmaxy()/2;
/* calculate the size of the image */ //計算圖像的大小
size=imagesize(x,y-ARROW_SIZE,x+2*ARROW_SIZE,y+ARROW_SIZE);
/* allocate memory to hold the image */ //重複直到一個鍵被按下
arrow=(int*)malloc(size);
/* grab the image */ //獲取圖像
getimage(x,y-ARROW_SIZE,x+2*ARROW_SIZE,y+ARROW_SIZE,arrow);
/* repeat until a key is pressed */
while(!kbhit())
{
/* plot new image */ //重新列印的圖像
draw_arrow(x,y);
delay(400); /* delay time */ //延遲時間
/* erase old image */ //刪除舊圖片
putimage(x,y-ARROW_SIZE,arrow,AND_PUT);
x+=2*ARROW_SIZE;
if(maxx-x<2*ARROW_SIZE) x=0;
}
/* clean up */ //清理
free(arrow);
closegraph();
return 0;
}
/* draw an arrow on the screen */ //在螢幕上畫一個箭頭
void draw_arrow(int x,int y)
{
moveto(x,y);
linerel(0,-1*ARROW_SIZE);
linerel(2*ARROW_SIZE,ARROW_SIZE);
linerel(-2*ARROW_SIZE,ARROW_SIZE);
linerel(0,-1*ARROW_SIZE);
}

相關詞條

熱門詞條

聯絡我們