SKCanvasView.DrawInSurface(SKSurface, SKImageInfo) Method

Definition

Caution

Use OnPaintSurface(SKPaintSurfaceEventArgs) instead.

Implement this to draw on the canvas.

public virtual void DrawInSurface (SkiaSharp.SKSurface surface, SkiaSharp.SKImageInfo info);
[System.Obsolete("Use OnPaintSurface(SKPaintSurfaceEventArgs) instead.")]
public virtual void DrawInSurface (SkiaSharp.SKSurface surface, SkiaSharp.SKImageInfo info);

Parameters

surface
SKSurface

The surface to draw on.

info
SKImageInfo

The information about the surface.

Attributes

Examples

public override void DrawInSurface (SKSurface surface, SKImageInfo info)
{
    // call the base method
    base.DrawInSurface (surface, info);

    var surfaceWidth = info.Width;
    var surfaceHeight = info.Height;

    var canvas = surface.Canvas;

    // draw on the canvas

    canvas.Flush ();
}

Remarks

There are two ways to draw on this surface: by overriding the DrawInSurface(SKSurface, SKImageInfo) method, or by attaching a handler to the PaintSurface event.

Important

If this method is overridden, then the base must be called, otherwise the event may not be fired.

Note

If SkiaSharp version v1.68.x or greater is being used, then the OnPaintSurface(SKPaintSurfaceEventArgs) method should be overridden instead of DrawInSurface(SKSurface, SKImageInfo).

Applies to