Function Name: imagesize
Function: Returns the number of bytes required to hold the bit image
Usage: unsigned far imagesize (int left, int. top, int right, int bottom);
program Example:
#include
#include
#include
#include
#define ARROW_SIZE 10
void Draw_arrow (int x, int y);
int main (void)
{
* Request Autodetection * *
int gdriver = detect, Gmode, errorcode;
void *arrow;
int x, y, Maxx;
unsigned int size;
/* Initialize graphics and local variables * *
Initgraph (&gdriver, &gmode, "");
/* Read result of initialization * *
ErrorCode = Graphresult ();
if (errorcode!= grOk)/* An error occurred * *
{
printf ("Graphics Error:%s\n", Grapherrormsg (ErrorCode));
printf ("Press any key to halt:");
Getch ();
Exit (1); /* Terminate with an error code * *
}
Maxx = Getmaxx ();
x = 0;
y = Getmaxy ()/2;
/* Draw the image to be grabbed * *
Draw_arrow (x, y);
/* Calculate the size of the image * *
Size = ImageSize (x, Y-arrow_size, x+ (4*arrow_size), y+arrow_size);
/* Allocate memory to hold the image * *
Arrow = malloc (size);
/* Grab the image * *
GetImage (x, Y-arrow_size, x+ (4*arrow_size), y+arrow_size, ARROW);
/* Repeat until a key is pressed * *
while (!kbhit ())
{
/* Erase old image * *
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);
}
/* Clean up/*
Free (arrow);
Closegraph ();
return 0;
}
void Draw_arrow (int x, int y)
{
/* Draw an arrow on the screen * *
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);
}