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

D3DImage Class

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

The D3DImage type exposes the following members.

  NameDescription
Public methodD3DImage()Initializes a new instance of the D3DImage class.
Public methodD3DImage(Double, Double)Initializes a new instance of the D3DImage class with the specified display resolution.
Top
  NameDescription
Public propertyCanFreezeGets a value that indicates whether the object can be made unmodifiable. (Inherited from Freezable.)
Public propertyDependencyObjectTypeGets the DependencyObjectType that wraps the CLR type of this instance.  (Inherited from DependencyObject.)
Public propertyDispatcherGets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.)
Public propertyHasAnimatedPropertiesGets a value that indicates whether one or more AnimationClock objects is associated with any of this object's dependency properties. (Inherited from Animatable.)
Public propertyHeightGets the height of the D3DImage. (Overrides ImageSource.Height.)
Public propertyIsFrontBufferAvailableGets a value that indicates whether a front buffer exists.
Public propertyIsFrozenGets a value that indicates whether the object is currently modifiable. (Inherited from Freezable.)
Public propertyIsSealedGets a value that indicates whether this instance is currently sealed (read-only). (Inherited from DependencyObject.)
Public propertyMetadataGets the metadata associated with the image source. (Overrides ImageSource.Metadata.)
Public propertyPixelHeightGets the height of the D3DImage, in pixels.
Public propertyPixelWidthGets the width of the D3DImage, in pixels.
Public propertyWidthGets the width of the D3DImage. (Overrides ImageSource.Width.)
Top
  NameDescription
Public methodAddDirtyRectSpecifies the area of the back buffer that changed.
Public methodApplyAnimationClock(DependencyProperty, AnimationClock)Applies an AnimationClock to the specified DependencyProperty. If the property is already animated, the SnapshotAndReplace handoff behavior is used. (Inherited from Animatable.)
Public methodApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior)Applies an AnimationClock to the specified DependencyProperty. If the property is already animated, the specified HandoffBehavior is used. (Inherited from Animatable.)
Public methodBeginAnimation(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.)
Public methodBeginAnimation(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.)
Public methodCheckAccessDetermines whether the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Public methodClearValue(DependencyProperty)Clears the local value of a property. The property to be cleared is specified by a DependencyProperty identifier. (Inherited from DependencyObject.)
Public methodClearValue(DependencyPropertyKey)Clears the local value of a read-only property. The property to be cleared is specified by a DependencyPropertyKey. (Inherited from DependencyObject.)
Public methodCloneCreates 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.
Protected methodCloneCoreMakes the instance a clone (deep copy) of the specified Freezable using base (non-animated) property values. (Overrides Freezable.CloneCore(Freezable).)
Public methodCloneCurrentValueCreates 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.
Protected methodCloneCurrentValueCoreMakes the instance a modifiable clone (deep copy) of the specified Freezable using current property values. (Overrides Freezable.CloneCurrentValueCore(Freezable).)
Public methodCoerceValueCoerces 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.)
Protected methodCopyBackBufferCreates a software copy of the D3DImage.
Protected methodCreateInstanceInitializes a new instance of the Freezable class. (Inherited from Freezable.)
Protected methodCreateInstanceCoreWhen implemented in a derived class, creates a new instance of the D3DImage derived class. (Overrides Freezable.CreateInstanceCore().)
Public methodEqualsDetermines whether a provided DependencyObject is equivalent to the current DependencyObject. (Inherited from DependencyObject.)
Protected methodFinalizeFrees resources and performs other cleanup operations before the D3DImage is reclaimed by garbage collection. (Overrides Object.Finalize().)
Public methodFreeze()Makes the current object unmodifiable and sets its IsFrozen property to true. (Inherited from Freezable.)
Protected methodFreezeCoreMakes the D3DImage unmodifiable or determines whether it can be made unmodifiable. (Overrides Animatable.FreezeCore(Boolean).)
Public methodGetAnimationBaseValueReturns the non-animated value of the specified DependencyProperty. (Inherited from Animatable.)
Public methodGetAsFrozenCreates 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.)
Protected methodGetAsFrozenCoreMakes the instance a frozen clone of the specified Freezable using base (non-animated) property values. (Overrides Freezable.GetAsFrozenCore(Freezable).)
Public methodGetCurrentValueAsFrozenCreates 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.)
Protected methodGetCurrentValueAsFrozenCoreMakes 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).)
Public methodGetHashCodeGets a hash code for this DependencyObject. (Inherited from DependencyObject.)
Public methodGetLocalValueEnumeratorCreates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject. (Inherited from DependencyObject.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetValueReturns the current effective value of a dependency property on this instance of a DependencyObject. (Inherited from DependencyObject.)
Public methodInvalidatePropertyRe-evaluates the effective value for the specified dependency property (Inherited from DependencyObject.)
Public methodLockLocks the D3DImage and enables operations on the back buffer.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnChangedCalled when the current Freezable object is modified. (Inherited from Freezable.)
Protected methodOnFreezablePropertyChanged(DependencyObject, DependencyObject)Ensures that appropriate context pointers are established for a DependencyObjectType data member that has just been set. (Inherited from Freezable.)
Protected methodOnFreezablePropertyChanged(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.)
Protected methodOnPropertyChangedOverrides the DependencyObject implementation of OnPropertyChanged to also invoke any Changed handlers in response to a changing dependency property of type Freezable. (Inherited from Freezable.)
Public methodReadLocalValueReturns the local value of a dependency property, if it exists. (Inherited from DependencyObject.)
Protected methodReadPreambleEnsures 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.)
Public methodSetBackBuffer(D3DResourceType, IntPtr)Assigns a Direct3D surface as the source of the back buffer.
Public methodSetBackBuffer(D3DResourceType, IntPtr, Boolean)Assigns a Direct3D surface as the source of the back buffer.
Public methodSetCurrentValueSets the value of a dependency property without changing its value source. (Inherited from DependencyObject.)
Public methodSetValue(DependencyProperty, Object)Sets the local value of a dependency property, specified by its dependency property identifier. (Inherited from DependencyObject.)
Public methodSetValue(DependencyPropertyKey, Object)Sets the local value of a read-only dependency property, specified by the DependencyPropertyKey identifier of the dependency property. (Inherited from DependencyObject.)
Protected methodShouldSerializePropertyReturns a value that indicates whether serialization processes should serialize the value for the provided dependency property. (Inherited from DependencyObject.)
Public methodToString() Creates a string representation of this object based on the current culture. (Inherited from ImageSource.)
Public methodToString(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.)
Public methodTryLockAttempts to lock the D3DImage and waits for the specified duration.
Public methodUnlockDecrements the lock count for the D3DImage.
Public methodVerifyAccessEnforces that the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Protected methodWritePostscriptRaises 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.)
Protected methodWritePreambleVerifies 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.)
Top
  NameDescription
Public eventChangedOccurs when the Freezable or an object it contains is modified. (Inherited from Freezable.)
Public eventIsFrontBufferAvailableChangedOccurs when the IsFrontBufferAvailable property changes.
Top
  NameDescription
Public fieldStatic memberIsFrontBufferAvailablePropertyIdentifies the IsFrontBufferAvailable dependency property.
Top
  NameDescription
Explicit interface implemetationPrivate methodIFormattable.ToStringFormats the value of the current instance using the specified format. (Inherited from ImageSource.)
Top

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.

Responding to an Unavailable Front Buffer when WPF Does not Fall 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.

Responding to an Unavailable Front Buffer when WPF Falls Back to Software Rendering

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.

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>

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5 SP1, 3.0 SP2

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.