D3DImage Class
An ImageSource that displays a user-created Direct3D surface.
Assembly: PresentationCore (in PresentationCore.dll)
XMLNS for XAML: Not mapped to an xmlns.
The D3DImage type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | D3DImage() | Initializes a new instance of the D3DImage class. |
![]() | D3DImage(Double, Double) | Initializes a new instance of the D3DImage class with the specified display resolution. |
| Name | Description | |
|---|---|---|
![]() | CanFreeze | Gets a value that indicates whether the object can be made unmodifiable. (Inherited from Freezable.) |
![]() | DependencyObjectType | Gets the DependencyObjectType that wraps the CLR type of this instance. (Inherited from DependencyObject.) |
![]() | Dispatcher | Gets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.) |
![]() | HasAnimatedProperties | Gets a value that indicates whether one or more AnimationClock objects is associated with any of this object's dependency properties. (Inherited from Animatable.) |
![]() | Height | Gets the height of the D3DImage. (Overrides ImageSource::Height.) |
![]() | IsFrontBufferAvailable | Gets a value that indicates whether a front buffer exists. |
![]() | IsFrozen | Gets a value that indicates whether the object is currently modifiable. (Inherited from Freezable.) |
![]() | IsSealed | Gets a value that indicates whether this instance is currently sealed (read-only). (Inherited from DependencyObject.) |
![]() | Metadata | Gets the metadata associated with the image source. (Overrides ImageSource::Metadata.) |
![]() | PixelHeight | Gets the height of the D3DImage, in pixels. |
![]() | PixelWidth | Gets the width of the D3DImage, in pixels. |
![]() | Width | Gets the width of the D3DImage. (Overrides ImageSource::Width.) |
| Name | Description | |
|---|---|---|
![]() | AddDirtyRect | Specifies the area of the back buffer that changed. |
![]() | ApplyAnimationClock(DependencyProperty, AnimationClock) | Applies an AnimationClock to the specified DependencyProperty. If the property is already animated, the SnapshotAndReplace handoff behavior is used. (Inherited from Animatable.) |
![]() | ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior) | Applies an AnimationClock to the specified DependencyProperty. If the property is already animated, the specified HandoffBehavior is used. (Inherited from Animatable.) |
![]() | BeginAnimation(DependencyProperty, AnimationTimeline) | Applies an animation to the specified DependencyProperty. The animation is started when the next frame is rendered. If the specified property is already animated, the SnapshotAndReplace handoff behavior is used. (Inherited from Animatable.) |
![]() | BeginAnimation(DependencyProperty, AnimationTimeline, HandoffBehavior) | Applies an animation to the specified DependencyProperty. The animation is started when the next frame is rendered. If the specified property is already animated, the specified HandoffBehavior is used. (Inherited from Animatable.) |
![]() | CheckAccess | Determines whether the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.) |
![]() | ClearValue(DependencyProperty) | Clears the local value of a property. The property to be cleared is specified by a DependencyProperty identifier. (Inherited from DependencyObject.) |
![]() | ClearValue(DependencyPropertyKey) | Clears the local value of a read-only property. The property to be cleared is specified by a DependencyPropertyKey. (Inherited from DependencyObject.) |
![]() | Clone | Creates a modifiable clone of this D3DImage object, making deep copies of this object's values. When copying dependency properties, this method copies resource references and data bindings (which may no longer resolve), but not animations or their current values. |
![]() | CloneCore | Makes the instance a clone (deep copy) of the specified Freezable using base (non-animated) property values. (Overrides Freezable::CloneCore(Freezable).) |
![]() | CloneCurrentValue | Creates a modifiable clone of this D3DImage object, making deep copies of this object's current values. Resource references, data bindings, and animations are not copied, but their current values are copied. |
![]() | CloneCurrentValueCore | Makes the instance a modifiable clone (deep copy) of the specified Freezable using current property values. (Overrides Freezable::CloneCurrentValueCore(Freezable).) |
![]() | CoerceValue | Coerces the value of the specified dependency property. This is accomplished by invoking any CoerceValueCallback function specified in property metadata for the dependency property as it exists on the calling DependencyObject. (Inherited from DependencyObject.) |
![]() | CopyBackBuffer | Creates a software copy of the D3DImage. |
![]() | CreateInstance | Initializes a new instance of the Freezable class. (Inherited from Freezable.) |
![]() | CreateInstanceCore | When implemented in a derived class, creates a new instance of the D3DImage derived class. (Overrides Freezable::CreateInstanceCore().) |
![]() | Equals | Determines whether a provided DependencyObject is equivalent to the current DependencyObject. (Inherited from DependencyObject.) |
![]() | Finalize | Frees resources and performs other cleanup operations before the D3DImage is reclaimed by garbage collection. (Overrides Object::Finalize().) |
![]() | Freeze() | Makes the current object unmodifiable and sets its IsFrozen property to true. (Inherited from Freezable.) |
![]() | FreezeCore | Makes the D3DImage unmodifiable or determines whether it can be made unmodifiable. (Overrides Animatable::FreezeCore(Boolean).) |
![]() | GetAnimationBaseValue | Returns the non-animated value of the specified DependencyProperty. (Inherited from Animatable.) |
![]() | GetAsFrozen | Creates a frozen copy of the Freezable, using base (non-animated) property values. Because the copy is frozen, any frozen sub-objects are copied by reference. (Inherited from Freezable.) |
![]() | GetAsFrozenCore | Makes the instance a frozen clone of the specified Freezable using base (non-animated) property values. (Overrides Freezable::GetAsFrozenCore(Freezable).) |
![]() | GetCurrentValueAsFrozen | Creates a frozen copy of the Freezable using current property values. Because the copy is frozen, any frozen sub-objects are copied by reference. (Inherited from Freezable.) |
![]() | GetCurrentValueAsFrozenCore | Makes the current instance a frozen clone of the specified Freezable. If the object has animated dependency properties, their current animated values are copied. (Overrides Freezable::GetCurrentValueAsFrozenCore(Freezable).) |
![]() | GetHashCode | Gets a hash code for this DependencyObject. (Inherited from DependencyObject.) |
![]() | GetLocalValueEnumerator | Creates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject. (Inherited from DependencyObject.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | GetValue | Returns the current effective value of a dependency property on this instance of a DependencyObject. (Inherited from DependencyObject.) |
![]() | InvalidateProperty | Re-evaluates the effective value for the specified dependency property (Inherited from DependencyObject.) |
![]() | Lock | Locks the D3DImage and enables operations on the back buffer. |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | OnChanged | Called when the current Freezable object is modified. (Inherited from Freezable.) |
![]() | OnFreezablePropertyChanged(DependencyObject, DependencyObject) | Ensures that appropriate context pointers are established for a DependencyObjectType data member that has just been set. (Inherited from Freezable.) |
![]() | OnFreezablePropertyChanged(DependencyObject, DependencyObject, DependencyProperty) | This member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. (Inherited from Freezable.) |
![]() | OnPropertyChanged | Overrides the DependencyObject implementation of OnPropertyChanged to also invoke any Changed handlers in response to a changing dependency property of type Freezable. (Inherited from Freezable.) |
![]() | ReadLocalValue | Returns the local value of a dependency property, if it exists. (Inherited from DependencyObject.) |
![]() | ReadPreamble | Ensures that the Freezable is being accessed from a valid thread. Inheritors of Freezable must call this method at the beginning of any API that reads data members that are not dependency properties. (Inherited from Freezable.) |
![]() | SetBackBuffer | Assigns a Direct3D surface as the source of the back buffer. |
![]() | SetCurrentValue | Sets the value of a dependency property without changing its value source. (Inherited from DependencyObject.) |
![]() | SetValue(DependencyProperty, Object) | Sets the local value of a dependency property, specified by its dependency property identifier. (Inherited from DependencyObject.) |
![]() | SetValue(DependencyPropertyKey, Object) | Sets the local value of a read-only dependency property, specified by the DependencyPropertyKey identifier of the dependency property. (Inherited from DependencyObject.) |
![]() | ShouldSerializeProperty | Returns a value that indicates whether serialization processes should serialize the value for the provided dependency property. (Inherited from DependencyObject.) |
![]() | ToString() | Creates a string representation of this object based on the current culture. (Inherited from ImageSource.) |
![]() | ToString(IFormatProvider) | Creates a string representation of this object based on the IFormatProvider passed in. If the provider is nullptr, the CurrentCulture is used. (Inherited from ImageSource.) |
![]() | TryLock | Attempts to lock the D3DImage and waits for the specified duration. |
![]() | Unlock | Decrements the lock count for the D3DImage. |
![]() | VerifyAccess | Enforces that the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.) |
![]() | WritePostscript | Raises the Changed event for the Freezable and invokes its OnChanged method. Classes that derive from Freezable should call this method at the end of any API that modifies class members that are not stored as dependency properties. (Inherited from Freezable.) |
![]() | WritePreamble | Verifies that the Freezable is not frozen and that it is being accessed from a valid threading context. Freezable inheritors should call this method at the beginning of any API that writes to data members that are not dependency properties. (Inherited from Freezable.) |
| Name | Description | |
|---|---|---|
![]() | Changed | Occurs when the Freezable or an object it contains is modified. (Inherited from Freezable.) |
![]() | IsFrontBufferAvailableChanged | Occurs when the IsFrontBufferAvailable property changes. |
| Name | Description | |
|---|---|---|
![]() ![]() | IsFrontBufferAvailableProperty | Identifies the IsFrontBufferAvailable dependency property. |
| Name | Description | |
|---|---|---|
![]() ![]() | IFormattable::ToString | Formats the value of the current instance using the specified format. (Inherited from 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.
Note |
|---|
Performance depends greatly on the settings of the Direct3D surface. For more information, see Performance Considerations for Direct3D9 and WPF Interoperability. |
Note |
|---|
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.MainWindow"
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="MainWindow" Height="300" Width="300" Background="PaleGoldenrod">
<Grid>
<Image x:Name="imgelt">
<Image.Source>
<i:D3DImage x:Name="d3dimg" />
</Image.Source>
</Image>
</Grid>
</Window>
- SecurityPermission
for access to unmanaged resources. Security action: InheritanceDemand. Associated enumeration: SecurityPermissionFlag::UnmanagedCode
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
