Click or drag to resize
CanvasImageSource Class
Derives from Windows.UI.Xaml.Media.Imaging.SurfaceImageSource and extends it to know about Canvas types. Most apps should use CanvasControl instead of directly managing their own CanvasImageSource.
Inheritance Hierarchy
SystemObject
  Windows.UI.Xaml.Media.ImagingSurfaceImageSource
    Microsoft.Graphics.Canvas.UI.XamlCanvasImageSource

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 CanvasImageSource : SurfaceImageSource, 
	ICanvasResourceCreatorWithDpi, ICanvasResourceCreator

The CanvasImageSource type exposes the following members.

Constructors
  NameDescription
Public methodCanvasImageSource(ICanvasResourceCreatorWithDpi, Size)
Initializes a new instance of the CanvasImageSource class.
Public methodCanvasImageSource(ICanvasResourceCreatorWithDpi, Single, Single)
Initializes a new instance of the CanvasImageSource class.
Public methodCanvasImageSource(ICanvasResourceCreator, Single, Single, Single)
Initializes a new instance of the CanvasImageSource class.
Public methodCanvasImageSource(ICanvasResourceCreator, Single, Single, Single, CanvasAlphaMode)
Initializes a new instance of the CanvasImageSource 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.
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(Color)
Returns a new drawing session for redrawing the entire image source.
Public methodCreateDrawingSession(Color, Rect)
Returns a new drawing session for updating a region of the image source.
Public methodRecreate
Recreates the underlying image source.
Top
Examples
var imageSource = new CanvasImageSource(canvasDevice, width, height, dpi);

imageControl.Source = imageSource;

using (var ds = imageSource.CreateDrawingSession(Colors.Black))
{
    // drawing code
}
See Also