複製鏈接
請複製以下鏈接發送給好友

imagesize

鎖定
imagesize是一種函數名,功能是返回保存位圖像所需的字節數。
中文名
imagesize
外文名
imagesize
功 能
返回保存位圖像所需的字節數

imagesize基本信息

用 法: unsigned far imagesize(int left, int top, int right, int bottom);
頭文件: conio.h

imagesize程序舉例

#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);