Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

D3DImage Class

Updated: January 2010

An ImageSource that displays a user-created Direct3D surface.

Namespace:  System.Windows.Interop
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: Not mapped to an xmlns.
[SecurityPermissionAttribute(SecurityAction.InheritanceDemand, UnmanagedCode = true)]
public class D3DImage : ImageSource

Use the D3DImage class to host Direct3D content in a Windows Presentation Foundation (WPF) application.

Call the Lock method to change the Direct3D content displayed by the D3DImage. Call the SetBackBuffer method to assign a Direct3D surface to a D3DImage. Call the AddDirtyRect method to track updates to the Direct3D surface. Call the Unlock method to display the changed areas.

The D3DImage class manages two display buffers, which are called the back buffer and the front buffer. The back buffer is your Direct3D surface. Changes to the back buffer are copied forward to the front buffer when you call the Unlock method.

Occasionally, the Direct3D device is unavailable causing the front buffer to be unavailable. This lack of availability can be caused by screen locking, full-screen exclusive Direct3D applications, user-switching, or other system activities. When this occurs, your WPF application is notified by handling the IsFrontBufferAvailableChanged event, and the rendering system releases its reference to the back buffer. When the Direct3D device is available again, the rendering system raises the IsFrontBufferAvailableChanged event to notify the WPF application. Your application restarts rendering by calling the SetBackBuffer method again with a valid Direct3D surface.

NoteNote:

Performance depends greatly on the settings of the Direct3D surface. For more information, see Performance Considerations for Direct3D9 and WPF Interoperability.

NoteNote:

The D3DImage class does not display Direct3D content over a Remote Desktop connection.

The following code example shows how to declare a D3DImage in XAML. You must map the System.Windows.Interop namespace, because it is not included in the default XAML namespaces. For more information, see Walkthrough: Hosting Direct3D9 Content in WPF.

    <Window x:Class="D3DHost.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:i="clr-namespace:System.Windows.Interop;assembly=PresentationCore"
    Title="Window1" Height="300" Width="300" Background="PaleGoldenrod">
    <Grid>
        <Image x:Name="imgelt">
            <Image.Source>
                <i:D3DImage x:Name="d3dimg" />
            </Image.Source>
        </Image>
    </Grid>
</Window>
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5 SP1, 3.0 SP2

Date

History

Reason

January 2010

Added note about Remote Desktop connection.

Information enhancement.

July 2008

Added topic for new class.

SP1 feature change.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.