
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>imagesize() get amount of mem needed to store screen image</b>
[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
imagesize() Get Amount of Mem Needed to Store Screen Image
#include <graphics.h>
unsigned far imagesize(left,top,right,bottom);
int left;
int top;
int right;
int bottom;
imagesize() is used to determine the amount of memory necessary to
store a portion of the screen, specified by the coordinates
('left','top'), ('right','bottom'). The value returned by imagesize()
should be used to allocate memory for storage. getimage() is used to
save the screen portion and putimage() is used to return it to the
screen.
Returns: The number of bytes necessary to store the specified
screen image. -1 is returned if the image is greater
than or equal to 64K bytes.
-------------------------------- Example ---------------------------------
The following statements create a rectangular area on the screen
which is to be saved. The amount of memory needed to save it is
determined and space is allocated for it. The area is saved, then
cleared and a message is written where the rectangle existed. The
original rectangle is then restored. The area in memory is then
deallocated.
#include <graphics.h>
int gdriver = DETECT;
int gmode;
main()
{
void *pict;
unsigned p_size;
int l = 100, t = 100, r = 300, b = 300;
initgraph(&gdriver,&gmode,"");
setfillstyle(HATCH_FILL,RED);
rectangle(l,t,r,b);
floodfill(l+10,t+10,WHITE);
outtextxy(l+50,t+100,"ORIGINAL SCREEN");
getch();
p_size = imagesize(l,t,r,b);
pict = malloc(p_size);
getimage(l,t,r,b,pict);
cleardevice();
rectangle(l,t,r,b);
outtextxy(l+50,t+100,"SCREEN SAVED,");
outtextxy(l+50,t+110,"THEN CLEARED");
getch();
putimage(l,t,pict,COPY_PUT);
outtextxy(l+50,t+110," (RESTORED)");
getch();
free(pict);
closegraph();
}
See Also: getimage() putimage()
Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson