_getimage Functions

Description

Store images in buffers.

#include <graph.h>

void __far _getimage( short x1, short y1, short x2, short y2,
char __huge *image );

void __far _getimage_w( double wx1, double wy1, double wx2, double wy2,
char __huge *image );

void __far _getimage_wxy( struct_wxycoord __far *pwxy1,
struct_wxycoord __far *pwxy2, char __huge *image );

x1, y1 Upper-left corner of bounding rectangle  
x2, y2 Lower-right corner of bounding rectangle  
wx1, wy1 Upper-left corner of bounding rectangle  
wx2, wy2 Lower-right corner of bounding rectangle  
pwxy1 Upper-left corner of bounding rectangle  
pwxy2 Lower-right corner of bounding rectangle  
image Storage buffer for screen image  

Remarks

The _getimage functions store the screen image defined by a specified bounding rectangle into the buffer pointed to by image.

The _getimage function defines the bounding rectangle with the view coordinates (x1, y1) and (x2, y2).

The _getimage_w function defines the bounding rectangle with the window coordinates (wx1, wy1) and (wx2, wy2).

The _getimage_wxy function defines the bounding rectangle with the window-coordinate pairs pwxy1 and pwxy2.

The buffer must be large enough to hold the image. You can determine the size by calling the appropriate _imagesize function at run time, or by using the formula described on the _imagesize reference page.

Return Value

None. Use _grstatus to check success.

Compatibility

Standards:None

16-Bit:DOS

32-Bit:None

See Also

_grstatus, _imagesize functions, _putimage functions

Example

/* GIMAGE.C: This example illustrates animation routines including:

* _imagesize _getimage _putimage

*/

#include <conio.h>

#include <stddef.h>

#include <stdlib.h>

#include <malloc.h>

#include <graph.h>

short action[5] = { _GPSET, _GPRESET, _GXOR, _GOR, _GAND };

char *descrip[5] = { "PSET ", "PRESET", "XOR ", "OR ", "AND " };

void exitfree( char __huge *buffer );

void main( void )

{

char __huge *buffer; /* Far pointer (with _fmalloc) could be used. */

long imsize;

short i, x, y = 30;

if( !_setvideomode( _MAXRESMODE ) )

exit( 1 );

/* Measure the image to be drawn and allocate memory for it. */

imsize = (size_t)_imagesize( -16, -16, +16, +16 );

buffer = _halloc( imsize, sizeof( char ) );

if ( buffer == (char __far *)NULL )

exit( 1 );

_setcolor( 3 );

for ( i = 0; i < 5; i++ )

{

/* Draw ellipse at new position and get a copy of it. */

x = 50; y += 40;

_ellipse( _GFILLINTERIOR, x - 15, y - 15, x + 15, y + 15 );

_getimage( x - 16, y - 16, x + 16, y + 16, buffer );

if( _grstatus() )

exitfree( buffer ); /* Quit on error */

/* Display action type and copy a row of ellipses with that type. */

_settextposition( 1, 1 );

_outtext( descrip[i] );

while( x < 260 )

{

x += 5;

_putimage( x - 16, y - 16, buffer, action[i] );

if( _grstatus() < 0 ) /* Ignore warnings, quit on errors. */

exitfree( buffer );

}

_getch();

}

exitfree( buffer );

}

void exitfree( char __huge *buffer )

{

_hfree( buffer );

exit( !_setvideomode( _DEFAULTMODE ) );

}