Re: capture the screen

Search this archive.

From: Jim Dutcher (dutcher@volny.cz)
Date: Sat 11 Dec 1999 - 04:28:28 IST


> Hi!
> I´m writing to know how can I capture the screen when I´m using svgalib
> (i mean in a graphic mode), I think i can use gl_getbox() but I have to
> save it in a BMP file that can be open with another graphic program on
> linux or windows :(
> Thanks!
>
> cristian
>
>

well, this is the BMP format (file structure):

BITMAPFILEHEADER
BITMAPINFOHEADER
RGBQUAD[0]
RGBQUAD[1]
.
.
.
RGBQUAD[n]

The BITMAPINFOHEADER and RGBQUADs are together called
BITMAPINFO
Picture "bits"

Here are the structures:

typedef struct tagBITMAPFILEHEADER
{
 WORD bfType;            // must be set to string "BM", identifies the file
type
 DWORD bfSize;                   // size of the file, used by programs which
load the file at once
 WORD bfReserved1;            // reserved for future used, must be set to 0
 WORD bfReserved2;            // reserved for future used, must be set to 0
 DWORD bfOffBits;               // adress of the first "bit" of the picture
} BITMAPFILEHEADER;

typedef struct tagBITMAPINFOHEADER
{
 DWORD biSize;            // size of the BITMAPINFOHEADER structure
 LONG biWidth;            // width of the picture
 LONG biHeight;            // height of the picture
 WORD biPlanes;            // number of planes, must be said to 1
 WORD biBitCount;            // number of bits used for one pixel, this may
be 1, 4, 8, 16, 24 or 32
 DWORD biCompression;            // type of the compression, set to 0, it
means no compression
 DWORD biSizeImage;                // size of the image (bits) this may be 0
for bitmaps without compression
 LONG biXPelsPerMeter;            // set to 0
 LONG biYPelsPerMeter;            // set to 0
 DWORD biClrUsed;                    // colors used, 0 means all colors are
used
 DWORD biClrImportant;            // number of important colors, set 0
} BITMAPINFOHEADER;

typedef struct tagRGBQUAD
{
 BYTE rgbBlue;                // blue (0..255)
 BYTE rgbGreen;            // green (0..255)
 BYTE rgbRed;                // red (0..255)
 BYTE rgbReserved;            // reserved, must be 0
} RGBQUAD;

typedef struct tagBITMAPINFO
{
 BITMAPINFOHEADER bmiHeader;
 RGBQUAD bmiColors[1];
} BITMAPINFO;

remember to use __attribute__((packed)) for every member of the structures
when using gcc

for example

rgbBlue __attribute__((packed))

RGBQUAD are used to define the palette, for true-color images there's
nothing
like this

see windows documentation to learn more

be careful about this
a picture like this in the file:

ooooooooooooooooooooooooooooo
o                                                      o
o                      o                              o
o                   o o o                           o
o                 o   o   o                         o
o                      o                              o
o                      o                              o
o                                                      o
ooooooooooooooooooooooooooooo

will be displayed like this:

ooooooooooooooooooooooooooooo
o                                                      o
o                      o                              o
o                      o                              o
o                 o   o    o                        o
o                   o o o                           o
o                      o                              o
o                                                      o
ooooooooooooooooooooooooooooo

that's it
bye


This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:22 IST