D3DImage Class
An ImageSource that displays a user-created Direct3D surface.
Assembly: PresentationCore (in PresentationCore.dll)
| 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(Int32Rect) | 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(Freezable) | 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(Freezable) | Makes the instance a modifiable clone (deep copy) of the specified Freezable using current property values.(Overrides Freezable.CloneCurrentValueCore(Freezable).) |
![]() | CoerceValue(DependencyProperty) | 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() | |
![]() | CreateInstanceCore() | When implemented in a derived class, creates a new instance of the D3DImage derived class.(Overrides Freezable.CreateInstanceCore().) |
![]() | Equals(Object) | 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() | |
![]() | FreezeCore(Boolean) | Makes the D3DImage unmodifiable or determines whether it can be made unmodifiable.(Overrides Animatable.FreezeCore(Boolean).) |
![]() | GetAnimationBaseValue(DependencyProperty) | Returns the non-animated value of the specified DependencyProperty.(Inherited from Animatable.) |
![]() | GetAsFrozen() | |
![]() | GetAsFrozenCore(Freezable) | Makes the instance a frozen clone of the specified Freezable using base (non-animated) property values.(Overrides Freezable.GetAsFrozenCore(Freezable).) |
![]() | GetCurrentValueAsFrozen() | |
![]() | GetCurrentValueAsFrozenCore(Freezable) | 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() | |
![]() | GetValue(DependencyProperty) | Returns the current effective value of a dependency property on this instance of a DependencyObject. (Inherited from DependencyObject.) |
![]() | InvalidateProperty(DependencyProperty) | 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() | |
![]() | OnChanged() | |
![]() | 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(DependencyPropertyChangedEventArgs) | 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(DependencyProperty) | Returns the local value of a dependency property, if it exists. (Inherited from DependencyObject.) |
![]() | ReadPreamble() | |
![]() | SetBackBuffer(D3DResourceType, IntPtr) | Assigns a Direct3D surface as the source of the back buffer. |
![]() | SetBackBuffer(D3DResourceType, IntPtr, Boolean) | Assigns a Direct3D surface as the source of the back buffer. |
![]() | SetCurrentValue(DependencyProperty, Object) | 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(DependencyProperty) | 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 null, the CurrentCulture is used. (Inherited from ImageSource.) |
![]() | TryLock(Duration) | 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() | |
![]() | WritePreamble() |
| Name | Description | |
|---|---|---|
![]() ![]() | IsFrontBufferAvailableProperty | Identifies the IsFrontBufferAvailable dependency property. |
| Name | Description | |
|---|---|---|
![]() | Changed | |
![]() | IsFrontBufferAvailableChanged | Occurs when the IsFrontBufferAvailable property changes. |
| Name | Description | |
|---|---|---|
![]() ![]() | IFormattable.ToString(String, IFormatProvider) | 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, where it is displayed on the hardware. Occasionally, the front buffer becomes 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. How your application responds to the front buffer becoming unavailable depends on whether WPF is enabled to fall back to software rendering. The SetBackBuffer method has an overload that takes a parameter that specifies whether WPF falls back to software rendering.
When you call the SetBackBuffer(D3DResourceType, IntPtr) overload or call the SetBackBuffer(D3DResourceType, IntPtr, Boolean) overload with the enableSoftwareFallback parameter set to false, the rendering system releases its reference to the back buffer when the front buffer becomes unavailable and nothing is displayed. When the front buffer is available again, the rendering system raises the IsFrontBufferAvailableChanged event to notify your WPF application. You can create an event handler for the IsFrontBufferAvailableChanged event to restart rendering again with a valid Direct3D surface. To restart rendering, you must call SetBackBuffer.
When you call the SetBackBuffer(D3DResourceType, IntPtr, Boolean) overload with the enableSoftwareFallback parameter set to true, the rendering system retains its reference to the back buffer when the front buffer becomes unavailable, so there is no need to call SetBackBuffer when the front buffer is available again. There may be situations where the user’s device becomes unavailable. When that occurs, call SetBackBuffer to release WPF’s reference to the back buffer. If you need to reset your device, call SetBackBuffer with the backBuffer parameter set to null, and then call SetBackBuffer again with backBuffer set to 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 when WPF renders in software, such as over a Remote Desktop connection, unless you call SetBackBuffer(D3DResourceType, IntPtr, Boolean) and specify true for the enableSoftwareFallback parameter. |
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>
for access to unmanaged resources. Security action: InheritanceDemand. Associated enumeration: SecurityPermissionFlag.UnmanagedCode
Available since 3.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.








