Mail Archives: djgpp/1994/03/18/03:59:01
Yesterday, I received a mail about how to capture a screen using the GRX
and LUG libraries.
The target is something like:
{
bitmap_hdr bitmap;
...
<here show what u wanna >
...
if ( capture_GRX_bitmap( &bitmap ) != -1 ) {
/* Fine !. Write it using LUG */
write_lug_file( "<the_name>", &bitmap );
/* Free memory */
freebitmap( &bitmap );
}
...
<what u wanna, close graphics and ...>
...
}
Remember that the output file format will be fixed using the given file
name (else use 'ad hoc' functions: write_gif_file, write_tga_file, ...).
The new function is ...
=================
/*
* This software is copyrighted as noted below. It may be freely copied,
* modified, and redistributed, provided that the copyright notice is
* preserved on all copies.
*
* There is no warranty or other guarantee of fitness for this software,
* it is provided solely "as is". Bug reports or fixes may be sent
* to the author, who may or may not act on them as he desires.
*
* You may not include this software in a program or other software product
* without supplying the source, or without informing the end-user that the
* source is available for no extra charge.
*
* If you modify this software, you should include a notice giving the
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*/
/*
* capture_grx.c - capture the graphics image displayed using the GRX library.
*
* Author: Raul Rivero
* Vicerrectorado de Estudiantes
* University of Oviedo
* Date: Thu Mar 17 1994
* Copyright (c) 1994, Raul Rivero
*
*/
#include <lug.h>
#include <lugfnts.h>
#include <grx.h>
capture_GRX_image( bitmap )
bitmap_hdr *bitmap;
{
register int i;
int numcolors;
int raux, gaux, baux;
byte *ptr;
/*
* Ooopppsss!, only 8 bitmap images. There is not an special reason but
* i have a 256 graphics board.
*/
if ( (numcolors = GrNumColors()) > 256 )
return -1;
/* Fill the image header */
bitmap->xsize = GrSizeX();
bitmap->ysize = GrSizeY();
bitmap->depth = no_bits(numcolors) + 1;
bitmap->colors = numcolors;
bitmap->magic = LUGUSED;
/* Alloc space for the color map ... */
bitmap->cmap = (byte *) Malloc( numcolors * 3 );
/* ... and get it ! */
for ( i = 0, ptr = bitmap->cmap; i < numcolors; i++ ) {
GrQueryColor( i, &raux, &gaux, &baux );
*ptr++ = raux;
*ptr++ = gaux;
*ptr++ = baux;
}
/* Get more :-) memory (raster information) */
bitmap->r = (byte *) Malloc( bitmap->xsize * bitmap->ysize );
/*
* DJGPP maps the memory video from the 0xd0000000 address,
* so our image buffer is ...
*/
bcopy( (byte *) 0xd0000000, bitmap->r, bitmap->xsize * bitmap->ysize );
/* And ... voila! ... it's done */
return 0;
}
=================
If someone can hack the routine to work with a true color board, please.
Cheers.
--
===================================
Raul Rivero
Vicerrectorado de Estudiantes
Universidad de Oviedo
Arguelles, 39, 2o.
33003 - Oviedo
Spain
---------------------------------
rivero AT pinon DOT ccu DOT uniovi DOT es
---------------------------------
"Es muy duro ser romantica y
ninfomana a la vez", Ariadna
Gil en el corto El Columpio.
===================================
- Raw text -