如何调整 SharpDX 的 texture2d 大小?我正在使用 SharpDX 复制屏幕,并使用 MediaFoundation 将纹理编码为视频文件。我的问题是,当我以全屏模式打开应用程序并且分辨率与系统分辨率不同时,我的录制内容出现空白屏幕。有没有更好的方法可以在编码到 mediafoundation 之前调整纹理大小而不会影响性能?我正在使用硬件加速。谢谢。
1 回答
It depends on how exactly you use Media Foundation, but you can use the Video Processor MFT explicitly. You need to add this MFT to the topology if you use IMFMediaSession/IMFTopology. Or initialize and process the samples with this MFT if you use Sink Writer. In this case you need to supply the DX manager to the MFT, using MFT_MESSAGE_SET_D3D_MANAGER.
This MFT is only available on Windows 8 and higher. So if you need to support an older Windows version you can use Video Resizer, but it is not hardware accelerated.
Another option to resize the texture would be to create a render target of the desired size and draw the texture to it. After that you need to feed that render target to the encoder.