void SoftwareGraphicsDevice::CaptureScreen(WindowManager &WM, Bitmap &B)
{
    int i, i2, Width, Height;
    RECT WindowCoord;
    RGBColor Color;

    GetClientRect(WM.CastWindows().GetHWND(), &WindowCoord);
    MapWindowPoints(WM.CastWindows().GetHWND(), GetDesktopWindow(), (LPPOINT)&WindowCoord, 2);

    Width = WindowCoord.right - WindowCoord.left;
    Height = WindowCoord.bottom - WindowCoord.top;    //get the Width/Height

    B.Allocate(Width, Height);                //allocate space

    for(i=0; i<Height; i++)
    {
        for(i2=0; i2<Width; i2++)
        {
            B[Height-i-1][i2] = Bmp[i][i2];    //load the current screen into B
        }
    }
}