Resizing a DXGI Resource or Texture2D in SharpDX

前端 未结 3 1134
盖世英雄少女心
盖世英雄少女心 2021-01-05 04:05

I want to resize a screen captured using the Desktop Duplication API in SharpDX. I am using the Screen Capture sample code from the SharpDX Samples repository, relevant port

3条回答
  •  悲&欢浪女
    2021-01-05 04:15

    You need to take your original source surface in GPU memory and Draw() it on to a smaller surface. This involves simple vector/pixel shaders, which some folks with simple needs would rather bypass.

    I would look to see if someone made a sprite lib for sharpdx. It should be a common "thing"...or using Direct2D (which is much more fun). Since D2D is just a user-mode library over D3D, it interops with D3D very easily.

    I've never used SharpDx, but fFrom memory you would do something like this:

    1.) Create an ID2D1Device, wrapping your existing DXGI Device (make sure your dxgi device creation flag has D3D11_CREATE_DEVICE_BGRA_SUPPORT)

    2.) Get the ID2D1DeviceContext from your ID2D1Device

    3.) Wrap your source and destination DXGI surfaces into D2D bitmaps with ID2D1DeviceContext::CreateBitmapFromDxgiSurface

    4.) ID2D1DeviceContext::SetTarget of your destination surface

    5.) BeginDraw, ID2D1DeviceContext::DrawBitmap, passing your source D2D bitmap. EndDraw

    6.) Save your destination

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题