DpiCompensationEffect Class |
Namespace: Microsoft.Graphics.Canvas.Effects
public sealed class DpiCompensationEffect : ICanvasEffect, IGraphicsEffect, IGraphicsEffectSource, ICanvasImage, IDisposable
The DpiCompensationEffect type exposes the following members.
Name | Description | |
---|---|---|
DpiCompensationEffect | Initializes a new instance of the DpiCompensationEffect class. |
Name | Description | |
---|---|---|
BorderMode | Border mode for edge pixels. Default value Soft. | |
BufferPrecision | Specifies what precision to use for intermediate buffers when drawing this effect. | |
CacheOutput | Enables caching the output from drawing this effect. | |
InterpolationMode | Interpolation mode. Default value Linear. | |
Name | Attaches a user-defined name string to the effect. | |
Source | Gets or sets the input source for DpiCompensation effect. | |
SourceDpi | Specifies the new DPI. Default value (96, 96). |
Name | Description | |
---|---|---|
Dispose | Releases all resources used by the effect. | |
GetBounds(ICanvasResourceCreator) | Retrieves the bounds of this DpiCompensationEffect. | |
GetBounds(ICanvasResourceCreator, Matrix3x2) | Retrieves the bounds of this DpiCompensationEffect. | |
GetInvalidRectangles | Queries what regions of the effect output have changed since it was last drawn. | |
GetRequiredSourceRectangle | Queries what part of an effect source image is needed to draw an output region. | |
GetRequiredSourceRectangles | Queries what parts of the effect source images are needed to draw an output region. | |
InvalidateSourceRectangle | Notifies the effect that one of its source images has changed. |
Supported by Win2D but not Windows.UI.Composition.
When a bitmap of different DPI than the target drawing session is used as an effect source image, an internal DpiCompensationEffect is automatically inserted in between the bitmap and the effect. This scales the bitmap to match the target DPI, which is usually what you want.
In a few cases, this automatic DPI scaling may not be desirable. For example, consider a 96 DPI bitmap which as part of an effect graph is being scaled up 16x using nearest neighbor image interpolation. The intent is to produce a crisply pixelated output, but if this app is run on a 144 DPI display, first the automatically inserted DpiCompensationEffect will scale up the image by a factor of 1.5 (to adjust for 144/96 DPI). This compensation uses linear interpolation, after which the 16x scale will be fed an undesirably blurry source image.
In situations like this, automatic DPI compensation can be overridden by inserting your own instance of DpiCompensationEffect in between the bitmap and the rest of the effect graph. There are two possible approaches:
This Windows Runtime type corresponds to the D2D DPI compensation effect.