Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>getimage() save a bit image of an area in memory</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 getimage()              Save a Bit Image of an Area in Memory

 #include   <graphics.h>

 void far   getimage(left,top,right bottom,bitmap);
 int        left;
 int        top;
 int        right;
 int        bottom;
 void far   *bitmap;


    getimage() copies an image from the screen to memory.  The
    rectangular screen area to be saved is defined by the coordinates
    ('left','top'), ('right','bottom'). 'bitmap' points to an area of
    memory that has been allocated for saving the image. The first two
    words of 'bitmap' hold the width and height of the rectangular area,
    with the image stored in the remainder. imagesize() should be used to
    determine the amount of memory necessary to store the bit image.

    Returns:    Nothing.

   -------------------------------- Example ---------------------------------

    The following statements create a rectangular area on the screen for
    saving. 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: imagesize() putimage()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson