Hi,
For that purpose I'm using the function GrBitBlt.
GrContext *pPic;
int w = x2 - x1 + 1;
int h = y2 - y1 + 1;
// Create a context in memory
pPic = GrCreateContext(w, h, NULL, NULL);
// Save the on-screen rectangle
if(pPic != NULL)
GrBitBlt(pPic, 0, 0, NULL, x1, y1, x2, y2, GrWRITE);
// ... overwrite the screen
// Restore the rectangle
if(pPic != NULL)
GrBitBlt(NULL, x1, y1, pPic, 0, 0, w, h, GrWRITE);
// And release the memory
GrDestroyContext(pPic);
This works fine for me. Hope that helps.
Josu Onandia
> -----Mensaje original-----
> De: J-P [SMTP:jstacey@plato.wadham.ox.ac.uk]
> Enviado el: viernes 12 de mayo de 2000 15:59
> Para: grx(a)gnu.de
> Asunto: Contexts and saving bits of the screen
>
> Hi,
>
> I am trying to implement rather basic "sprites" in GRX (not so complicated
> that I want to proceed to e.g. Allegro). To this end I'd like to write
> over, but then *retrieve*, bits of graphics on the screen.
>
> Essentially, I would like a filled box to be drawn on existing screen
> content, but the existing content to be "saved" somehow and put back on
> the screen (analogous to conio.h's puttext() and gettext() functions) once
> the filled box is no longer necessary.
>
> I was hoping perhaps to use GrContexts and GetImageFromContext() for this,
> but I'm not entirely sure how to go about it. My first few attempts
> resulted in seg-faults. What is the name of the "default context" that
> GrSetMode() sets up?
>
> Just a routine that buffers the screen content of the box (x1,y1,x2,y2)
> would help.
>
> Any help gratefully received.
>
> J-P Stacey