Click or drag to resize
DisplacementMapEffect Class
[NoComposition] Displaces the pixels of an input image by the intensity values of a second image.
Inheritance Hierarchy
SystemObject
  Microsoft.Graphics.Canvas.EffectsDisplacementMapEffect

Namespace:  Microsoft.Graphics.Canvas.Effects
Assembly:  Microsoft.Graphics.Canvas (in Microsoft.Graphics.Canvas.dll) Version: 0.0.0.0
Syntax
C#
public sealed class DisplacementMapEffect : ICanvasEffect, 
	IGraphicsEffect, IGraphicsEffectSource, ICanvasImage, IDisposable

The DisplacementMapEffect type exposes the following members.

Constructors
  NameDescription
Public methodDisplacementMapEffect
Initializes a new instance of the DisplacementMapEffect class.
Top
Properties
  NameDescription
Public propertyAmount
Scales the intensity of the displacement. The higher you set this property, the more the effect displaces the pixels. Default value 0.
Public propertyBufferPrecision
Specifies what precision to use for intermediate buffers when drawing this effect.
Public propertyCacheOutput
Enables caching the output from drawing this effect.
Public propertyDisplacement
Gets or sets the displacement image which is used to distort the main Source image.
Public propertyName
Attaches a user-defined name string to the effect.
Public propertySource
Gets or sets the main input source for DisplacementMap effect.
Public propertyXChannelSelect
The effect extracts the intensity from this color channel and uses it to spatially displace the image in the X direction. Default value Alpha.
Public propertyYChannelSelect
The effect extracts the intensity from this color channel and uses it to spatially displace the image in the Y direction. Default value Alpha.
Top
Methods
  NameDescription
Public methodDispose
Releases all resources used by the effect.
Public methodGetBounds(ICanvasResourceCreator)
Retrieves the bounds of this DisplacementMapEffect.
Public methodGetBounds(ICanvasResourceCreator, Matrix3x2)
Retrieves the bounds of this DisplacementMapEffect.
Public methodGetInvalidRectangles
Queries what regions of the effect output have changed since it was last drawn.
Public methodCode exampleGetRequiredSourceRectangle
Queries what part of an effect source image is needed to draw an output region.
Public methodGetRequiredSourceRectangles
Queries what parts of the effect source images are needed to draw an output region.
Public methodInvalidateSourceRectangle
Notifies the effect that one of its source images has changed.
Top
Remarks

Supported by Win2D but not Windows.UI.Composition.

The locations of the pixels in the output are determined using this formula:

result[x,y] = Source[x + Amount * (XChannelSelect(Displacement[x,y]) - 0.5), y + Amount * (YChannelSelect(Displacement[x,y]) - 0.5)]

The effect resamples the input image according to the scale property and the intensity of the displacement image. It uses bilinear interpolation if sampling from between pixels in the input image.

This effect works on straight and premultiplied alpha images. The output alpha format is the same as the input format.

When using this effect with InvalidateSourceRectangle, GetRequiredSourceRectangle, or GetRequiredSourceRectangles, its Source property corresponds to source index #0, and Displacement to source index #1.

This Windows Runtime type corresponds to the D2D Displacement map effect.

See Also