Hi Everyone,
In my desktop application (using SlimDX & DX11 ) I need to make a snapshot of a rendered window. I use the following code to save the bitmap of the current back buffer:
var context = device.ImmediateContext;
var srcTex = renderTarget.Resource as Texture2D;
var desc = srcTex.Description;
desc.BindFlags = BindFlags.None;
desc.Usage = ResourceUsage.Staging;
desc.CpuAccessFlags = CpuAccessFlags.Read;
desc.SampleDescription = new SampleDescription(1, 0);
Texture2D staging = new Texture2D(device, desc);
context.CopyResource(srcTex, staging);
Texture2D.ToFile(context, staging, ImageFileFormat.Png, "c:/Temp/Screenshot.png");
This code works fine, if my renderTarget is not multisampled. If the renderTarget is multisampled ( as needed for anti-aliasing) I got blank image. Does anybody know a way to get a bitmap snapshot from a multisampled render target?