Bool cdxgraph: snapshotbitmap (const char * OUTFILE)
{
If (mbasicvideo)
{
Long bitmapsize = 0;
If (succeeded (mbasicvideo-> getcurrentimage (& bitmapsize, 0 )))
{
Bool pass = false;
Unsigned char * buffer = new unsigned char [bitmapsize];
If (SUCCEEDED (mBasicVideo-> GetCurrentImage (& bitmapSize, (long *) buffer )))
{
BITMAPFILEHEADER hdr;
LPBITMAPINFOHEADER lpbi;
Lpbi = (LPBITMAPINFOHEADER) buffer;
Int nColors = 1 <lpbi-> biBitCount;
If (nColors> 256) nColors = 0;
Hdr. bfType = (WORD) ('M' <8) | 'B'); // always is "BM"
Hdr. bfSize = bitmapSize + sizeof (hdr );
Hdr. bfReserved1 = 0;
Hdr. bfReserved2 = 0;
Hdr. bfOff Bits = (DWORD) (sizeof (BITMAPFILEHEADER) + lpbi-> biSize + nColors * sizeof (RGBQUAD ));
Cfile bitma pfile (OUTFILE, cfile: modereadwrite | cfile: modecreate | cfile: typebinary );
Bitmapfile. Write (& HDR, sizeof (bitmapfileheader ));
Bitmapfile. Write (buffer, bitmapsize );
Bitmapfile. Close ();
Pass = true;
}
Delete [] buffer;
Return pass;
}
}
Return false;
}}