Method CreateBufferedImage
- Namespace
- PaintDotNet.Direct2D1
- Assembly
- PaintDotNet.Windows.Framework.dll
CreateBufferedImage(IDeviceContext, IDeviceImage)
Creates a buffered version of the given image. This can be used to work around limitations in Direct2D's
effect rendering system that can result in an InvalidGraphConfigurationException when an
IDeviceImage is used both in an effect graph and in a command list.
public static IBufferedImage CreateBufferedImage(this IDeviceContext deviceContext, IDeviceImage image)
Parameters
deviceContext
IDeviceContextimage
IDeviceImage
Returns
Remarks
If you get an InvalidGraphConfigurationException for an effect graph that otherwise looks
correct, use this method to wrap any IDeviceImages that are used by command lists which are
part of the effect graph that is causing the error. The command list(s) at fault may not be yours; they are
often contained within DynamicImages, for instance. The IDeviceImage may still be
set as the input for the DynamicImage, but the other nodes in the effect graph should use the
wrapper created by this method.
When the Direct2D debug layer and Visual Studio's mixed-mode debugging ("Enable debugging for managed and
native code together") are both enabled, you would see the following error:
A command list cannot reference effects which are part of effect graphs that consume the command list.
See also: D1159: Invalid Command List topologyAn example of an effect graph that can cause this error:
IDeviceImage --> SampleMapRenderer
| |
| |
v v
CompositeEffect
In this example, the IDeviceImage is used as an input for both a SampleMapRenderer and a CompositeEffect. The SampleMapRenderer, which implements DynamicImage, internally uses several effects and command lists to produce its output. In this case, the SampleMapRenderer should still be given the original IDeviceImage, while the CompositeEffect should use the buffered image:
IDeviceImage --> SampleMapRenderer
| |
v |
IBufferedImage |
| |
v v
CompositeEffect