使用direct3d缩放表面大小

时间:2015-03-16 10:29:48

标签: c++ directx direct3d

我制作一个截图的程序,我使用GetFrontBufferData和D3DXSaveSurfaceToFile。所有屏幕截图都保存在原始显示器分辨率我需要能够以不同的分辨率保存它们。我怎么能这样做?

ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS));

    d3dpp.Windowed = TRUE;
    d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
    d3dpp.BackBufferFormat = ddm.Format;
    d3dpp.BackBufferHeight = nDisplayHeight = gScreenRect.bottom = ddm.Height;
    d3dpp.BackBufferWidth = nDisplayWidth = gScreenRect.right = ddm.Width;
    d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.hDeviceWindow = hWnd;
    d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
    d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;

    g_pD3D->CreateDevice(i, D3DDEVTYPE_REF, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice);
    //g_pd3dDevice->GetRenderTarget(0, &g_pSurface);
    g_pd3dDevice->CreateOffscreenPlainSurface(ddm.Width, ddm.Height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &g_pSurface, NULL);
    SetCursor(LoadCursor(NULL, IDC_WAIT));
    g_pd3dDevice->GetFrontBufferData(0, g_pSurface);

    D3DXSaveSurfaceToFile(argv[0], D3DXIFF_BMP, g_pSurface, NULL, NULL);

0 个答案:

没有答案