SKSurface Class

Definition

Represents the backend/results of drawing to a canvas.

public class SKSurface : SkiaSharp.SKObject
Inheritance

Examples

var info = new SKImageInfo(256, 256);
using (var surface = SKSurface.Create(info)) {
    SKCanvas canvas = surface.Canvas;

    canvas.Clear(SKColors.White);

    // configure our brush
    var redBrush = new SKPaint {
        Color = new SKColor(0xff, 0, 0),
        IsStroke = true
    };
    var blueBrush = new SKPaint {
        Color = new SKColor(0, 0, 0xff),
        IsStroke = true
    };

    for (int i = 0; i < 64; i += 8) {
        var rect = new SKRect(i, i, 256 - i - 1, 256 - i - 1);
        canvas.DrawRect(rect, (i % 16 == 0) ? redBrush : blueBrush);
    }
}

The example above produces the following:

SKSurface

Remarks

The surface represents the backend/results of drawing to a canvas. For raster drawing, the surface will be pixels, but (for example) when drawing into a PDF or SKPicture canvas, the surface stores the recorded commands.

The surface always has non-zero dimensions. If there is a request for a new surface, and either of the requested dimensions are zero, then null will be returned.

Once you create a surface with one of its Create methods, you can draw into the canvas returned by the Canvas property. Once the drawing is complete, you can retrieve an SKImage by calling the Snapshot method.

Properties

Canvas

Gets the canvas for this surface which can be used for drawing into it.

Handle

Gets or sets the handle to the underlying native object.

(Inherited from SKObject)
IgnorePublicDispose

Gets or sets a value indicating whether the call the public Dispose() should be no-op.

(Inherited from SKNativeObject)
IsDisposed

Gets or sets a value indicating whether the object has already been disposed.

(Inherited from SKNativeObject)
OwnsHandle

Gets a value indicating whether this object should destroy the underlying native object.

(Inherited from SKObject)
SurfaceProperties

Gets the surface property configuration.

SurfaceProps

Gets the surface property configuration.

Methods

Create(GRContext, Boolean, SKImageInfo)

Creates a new surface whose contents will be drawn to an offscreen render target, allocated by the surface.

Create(GRContext, Boolean, SKImageInfo, Int32)

Creates a new surface whose contents will be drawn to an offscreen render target, allocated by the surface.

Create(GRContext, Boolean, SKImageInfo, Int32, GRSurfaceOrigin)

Creates a new surface whose contents will be drawn to an offscreen render target, allocated by the surface.

Create(GRContext, Boolean, SKImageInfo, Int32, GRSurfaceOrigin, SKSurfaceProperties, Boolean)

Creates a new surface whose contents will be drawn to an offscreen render target, allocated by the surface.

Create(GRContext, Boolean, SKImageInfo, Int32, SKSurfaceProperties)

Creates a new surface whose contents will be drawn to an offscreen render target, allocated by the surface.

Create(GRContext, Boolean, SKImageInfo, Int32, SKSurfaceProps)

Creates a new surface whose contents will be drawn to an offscreen render target, allocated by the surface.

Create(GRContext, Boolean, SKImageInfo, SKSurfaceProperties)

Creates a new surface whose contents will be drawn to an offscreen render target, allocated by the surface.

Create(GRContext, GRBackendRenderTarget, GRSurfaceOrigin, SKColorType)

Wraps a pre-existing backend 3D API render target as a surface.

Create(GRContext, GRBackendRenderTarget, GRSurfaceOrigin, SKColorType, SKColorSpace)

Wraps a pre-existing backend 3D API render target as a surface.

Create(GRContext, GRBackendRenderTarget, GRSurfaceOrigin, SKColorType, SKColorSpace, SKSurfaceProperties)

Wraps a pre-existing backend 3D API render target as a surface.

Create(GRContext, GRBackendRenderTarget, GRSurfaceOrigin, SKColorType, SKSurfaceProperties)

Wraps a pre-existing backend 3D API render target as a surface.

Create(GRContext, GRBackendRenderTarget, SKColorType)

Wraps a pre-existing 3D API render target as a surface.

Create(GRContext, GRBackendRenderTarget, SKColorType, SKSurfaceProperties)

Wraps a pre-existing backend 3D API render target as a surface.

Create(GRContext, GRBackendRenderTargetDesc)

Wraps a pre-existing 3D API render target as a surface.

Create(GRContext, GRBackendRenderTargetDesc, SKSurfaceProps)

Wraps a pre-existing 3D API render target as a surface.

Create(GRContext, GRBackendTexture, GRSurfaceOrigin, Int32, SKColorType)

Wraps a pre-existing backend 3D API texture as a surface.

Create(GRContext, GRBackendTexture, GRSurfaceOrigin, Int32, SKColorType, SKColorSpace)

Wraps a pre-existing backend 3D API texture as a surface.

Create(GRContext, GRBackendTexture, GRSurfaceOrigin, Int32, SKColorType, SKColorSpace, SKSurfaceProperties)

Wraps a pre-existing backend 3D API texture as a surface.

Create(GRContext, GRBackendTexture, GRSurfaceOrigin, Int32, SKColorType, SKSurfaceProperties)

Wraps a pre-existing backend 3D API texture as a surface.

Create(GRContext, GRBackendTexture, GRSurfaceOrigin, SKColorType)

Wraps a pre-existing backend 3D API texture as a surface.

Create(GRContext, GRBackendTexture, GRSurfaceOrigin, SKColorType, SKSurfaceProperties)

Wraps a pre-existing backend 3D API texture as a surface.

Create(GRContext, GRBackendTexture, SKColorType)

Wraps a pre-existing 3D API texture as a surface.

Create(GRContext, GRBackendTexture, SKColorType, SKSurfaceProperties)

Wraps a pre-existing backend 3D API texture as a surface.

Create(GRContext, GRBackendTextureDesc)

Wraps a pre-existing 3D API texture as a surface.

Create(GRContext, GRBackendTextureDesc, SKSurfaceProps)

Wraps a pre-existing 3D API texture as a surface.

Create(GRContext, GRGlBackendTextureDesc)

Wraps a pre-existing OpenGL texture as a surface.

Create(GRContext, GRGlBackendTextureDesc, SKSurfaceProps)

Wraps a pre-existing OpenGL texture as a surface.

Create(Int32, Int32, SKColorType, SKAlphaType)

Creates a new surface with the specified image parameters.

Create(Int32, Int32, SKColorType, SKAlphaType, IntPtr, Int32)

Creates a new surface with the specified image parameters using a provided buffer.

Create(Int32, Int32, SKColorType, SKAlphaType, IntPtr, Int32, SKSurfaceProps)

Creates a new surface with the specified image parameters using a provided buffer and surface properties.

Create(Int32, Int32, SKColorType, SKAlphaType, SKSurfaceProps)

Creates a new surface with the specified image parameters and surface properties.

Create(SKImageInfo)

Creates a new surface with the specified image parameters.

Create(SKImageInfo, Int32)

Creates a new surface from the specified image parameters.

Create(SKImageInfo, Int32, SKSurfaceProperties)

Creates a new surface from the specified image parameters and surface properties.

Create(SKImageInfo, IntPtr)

Creates a new surface with the specified image parameters using a provided buffer.

Create(SKImageInfo, IntPtr, Int32)

Creates a new surface with the specified image parameters using a provided buffer.

Create(SKImageInfo, IntPtr, Int32, SKSurfaceProperties)

Creates a new surface from the specified image parameters, the provided buffer and surface properties.

Create(SKImageInfo, IntPtr, Int32, SKSurfaceProps)

Creates a new surface from the specified image parameters, the provided buffer and surface properties.

Create(SKImageInfo, IntPtr, Int32, SKSurfaceReleaseDelegate, Object)

Creates a new surface with the specified image parameters using a provided buffer.

Create(SKImageInfo, IntPtr, Int32, SKSurfaceReleaseDelegate, Object, SKSurfaceProperties)

Creates a new surface with the specified image parameters using a provided buffer.

Create(SKImageInfo, IntPtr, SKSurfaceProperties)

Creates a new surface from the specified image parameters and surface properties.

Create(SKImageInfo, SKSurfaceProperties)

Creates a new surface from the specified image parameters and surface properties.

Create(SKImageInfo, SKSurfaceProps)

Creates a new surface from the specified image parameters and surface properties.

Create(SKPixmap)

Creates a new surface with the specified pixmap.

Create(SKPixmap, SKSurfaceProperties)

Creates a new surface with the specified pixmap and surface properties.

Create(SKPixmap, SKSurfaceProps)

Creates a new surface with the specified pixmap and surface properties.

CreateAsRenderTarget(GRContext, GRBackendTexture, GRSurfaceOrigin, Int32, SKColorType)

Wraps a pre-existing backend 3D API texture as a surface.

CreateAsRenderTarget(GRContext, GRBackendTexture, GRSurfaceOrigin, Int32, SKColorType, SKColorSpace)

Wraps a pre-existing backend 3D API texture as a surface.

CreateAsRenderTarget(GRContext, GRBackendTexture, GRSurfaceOrigin, Int32, SKColorType, SKColorSpace, SKSurfaceProperties)

Wraps a pre-existing backend 3D API texture as a surface.

CreateAsRenderTarget(GRContext, GRBackendTexture, GRSurfaceOrigin, Int32, SKColorType, SKSurfaceProperties)

Wraps a pre-existing backend 3D API texture as a surface.

CreateAsRenderTarget(GRContext, GRBackendTexture, GRSurfaceOrigin, SKColorType)

Wraps a pre-existing backend 3D API texture as a surface.

CreateAsRenderTarget(GRContext, GRBackendTexture, GRSurfaceOrigin, SKColorType, SKSurfaceProperties)

Wraps a pre-existing backend 3D API texture as a surface.

CreateAsRenderTarget(GRContext, GRBackendTexture, SKColorType)

Wraps a pre-existing backend 3D API texture as a surface.

CreateAsRenderTarget(GRContext, GRBackendTexture, SKColorType, SKSurfaceProperties)

Wraps a pre-existing backend 3D API texture as a surface.

CreateAsRenderTarget(GRContext, GRBackendTextureDesc)

Wraps a pre-existing backend 3D API texture as a surface.

CreateAsRenderTarget(GRContext, GRBackendTextureDesc, SKSurfaceProps)

Wraps a pre-existing backend 3D API texture as a surface.

CreateAsRenderTarget(GRContext, GRGlBackendTextureDesc)

Wraps a pre-existing backend OpenGL texture as a surface.

CreateAsRenderTarget(GRContext, GRGlBackendTextureDesc, SKSurfaceProps)

Wraps a pre-existing backend OpenGL texture as a surface.

CreateNull(Int32, Int32)

Creates a new surface without any backing pixels.

Dispose()

Releases all resources used by this SKNativeObject.

(Inherited from SKNativeObject)
Dispose(Boolean)

Releases the unmanaged resources used by the SKSurface and optionally releases the managed resources.

DisposeInternal()

Triggers a dispose, ignoring the value of IgnorePublicDispose.

(Inherited from SKNativeObject)
DisposeManaged()

Implemented by derived SKObject types to destroy any managed objects.

(Inherited from SKObject)
DisposeNative()

Implemented by derived SKObject types to destroy any native objects.

(Inherited from SKObject)
Draw(SKCanvas, Single, Single, SKPaint)

Draws the current surface on the specified canvas.

PeekPixels()

Returns the pixels, if they are available.

PeekPixels(SKPixmap)

Returns the pixmap of the surface.

ReadPixels(SKImageInfo, IntPtr, Int32, Int32, Int32)

Copies the pixels from the surface into the specified buffer.

Snapshot()

Takes a snapshot of the surface and returns it as an image.

Applies to