Click or drag to resize
CanvasVirtualImageSource Class
Provides a virtualized ImageSource that can be used with XAML controls.
Inheritance Hierarchy
SystemObject
  Microsoft.Graphics.Canvas.UI.XamlCanvasVirtualImageSource

Namespace:  Microsoft.Graphics.Canvas.UI.Xaml
Assembly:  Microsoft.Graphics.Canvas (in Microsoft.Graphics.Canvas.dll) Version: 0.0.0.0
Syntax
C#
public sealed class CanvasVirtualImageSource : ICanvasResourceCreatorWithDpi, 
	ICanvasResourceCreator

The CanvasVirtualImageSource type exposes the following members.

Constructors
  NameDescription
Public methodCanvasVirtualImageSource(ICanvasResourceCreatorWithDpi, Size)
Initializes a new instance of the CanvasVirtualImageSource class.
Public methodCanvasVirtualImageSource(ICanvasResourceCreatorWithDpi, Single, Single)
Initializes a new instance of the CanvasVirtualImageSource class.
Public methodCanvasVirtualImageSource(ICanvasResourceCreator, Single, Single, Single)
Initializes a new instance of the CanvasVirtualImageSource class.
Public methodCanvasVirtualImageSource(ICanvasResourceCreator, Single, Single, Single, CanvasAlphaMode)
Initializes a new instance of the CanvasVirtualImageSource class.
Top
Properties
  NameDescription
Public propertyAlphaMode
Returns the alpha mode for this image source that was passed in to the constructor.
Public propertyDevice
Gets the device used by this image source.
Public propertyDpi
Gets the dots-per-inch (DPI) of this image source.
Public propertySize
Gets the size of the image source, in device independent pixels (DIPs).
Public propertySizeInPixels
Gets the size of the image source, in pixels.
Public propertySource
Gets the VirtualSurfaceImageSource wrapped by this object.
Top
Methods
  NameDescription
Public methodConvertDipsToPixels
Converts units from device independent pixels (DIPs) to physical pixels based on the DPI of this image source.
Public methodConvertPixelsToDips
Converts units from physical pixels to device independent pixels (DIPs) based on the DPI of this image source.
Public methodCreateDrawingSession
Returns a new drawing session for updating a region of the image source.
Public methodInvalidate
Marks the entire image as needing to be redrawn.
Public methodInvalidate(Rect)
Marks a region of the image as needing to be redrawn.
Public methodRaiseRegionsInvalidatedIfAny
Raises RegionsInvalidated if there are any invalid regions.
Public methodRecreate
Recreates the underlying image source associating it with a different CanvasDevice.
Public methodResize(Size)
Resizes the virtual image.
Public methodResize(Single, Single)
Resizes the virtual image.
Public methodResize(Single, Single, Single)
Resizes the virtual image and possibly changes the DPI.
Public methodResumeDrawingSession
Resumes a previously suspended drawing session.
Public methodSuspendDrawingSession
Suspends a drawing session so that it may be resumed on another thread.
Top
Events
  NameDescription
Public eventRegionsInvalidated
Occurs when a region of the image needs redrawing.
Top
Remarks

A CanvasVirtualImageSource can be sized much larger than the largest image that Win2D can render to. CanvasVirtualImageSource provides events to indicate when regions of the image need to be redrawn.

Examples
var imageSource = new CanvasVirtualImageSource(canvasDevice, width, height, dpi);
imageControl.Source = imageSource.Source;
imageSource.RegionsInvalidated += ImageSource_RegionsInvalidated;

private void ImageSource_RegionsInvalidated(CanvasVirtualImageSource sender, CanvasRegionsInvalidatedEventArgs args)
{
    foreach (var region in args.InvalidatedRegions)
    {
        using (var ds = sender.CreateDrawingSession(clearColor, region))
        {
            // drawing commands
        }
    }
}
See Also