SKManagedStream Class

Definition

Wraps a Stream into a SKStreamAsset (a seekable, rewindable Skia stream)

public class SKManagedStream : SkiaSharp.SKAbstractManagedStream
Inheritance

Examples

public static void BitmapShader (SKCanvas canvas, int width, int height)
{
    var assembly = typeof(Demos).GetTypeInfo ().Assembly;

    // load the image from the embedded resource stream
    using (var resource = assembly.GetManifestResourceStream ("embedded.png"))
    using (var stream = new SKManagedStream(resource))
    using (var source = SKBitmap.Decode (stream)) {
        var matrix = SKMatrix.MakeRotation (30.0f);
        using (var shader = SKShader.CreateBitmap (source, SKShaderTileMode.Repeat, SKShaderTileMode.Repeat, matrix))
        using (var paint = new SKPaint ()) {
            paint.IsAntialias = true;
            paint.Shader = shader;

            // tile the bitmap
            canvas.Clear (SKColors.White);
            canvas.DrawPaint (paint);
        }
    }
}

Remarks

The following example shows how to wrap a Stream that represents a stream into an embedded resource in an assembly and use it with SkiaSharp APIs that use resources:

Constructors

SKManagedStream(Stream)

Creates a new read-only stream from a Stream.

SKManagedStream(Stream, Boolean)

Creates a new read-only stream from a Stream, can optionally dispose the provided stream when this stream is disposed.

Properties

Handle

Gets or sets the handle to the underlying native object.

(Inherited from SKObject)
HasLength

Gets a value indicating whether this stream can report it's total length.

(Inherited from SKStream)
HasPosition

Gets a value indicating whether this stream can report it's current position.

(Inherited from SKStream)
IgnorePublicDispose

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

(Inherited from SKNativeObject)
IsAtEnd

Gets a value indicating whether all the bytes in the stream have been read.

(Inherited from SKStream)
IsDisposed

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

(Inherited from SKNativeObject)
Length

Gets the total length of the stream. If this is not supported, the length will be reported as 0.

(Inherited from SKStream)
OwnsHandle

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

(Inherited from SKObject)
Position

Gets the current position in the stream. If this is not supported, the position will be reported as 0.

(Inherited from SKStream)

Methods

CopyTo(SKWStream)

Copy the contents of this stream into the destination stream.

Dispose()

Releases all resources used by this SKNativeObject.

(Inherited from SKNativeObject)
Dispose(Boolean)

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

DisposeInternal()

Triggers a dispose, ignoring the value of IgnorePublicDispose.

(Inherited from SKNativeObject)
DisposeManaged()

Implemented by derived SKNativeObject types to destroy any managed objects.

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 SKAbstractManagedStream)
DisposeUnownedManaged() (Inherited from SKObject)
GetMemoryBase()

Returns the memory address of the data if the stream is a memory stream.

(Inherited from SKStream)
Move(Int32)

Seeks to an relative offset in the stream.

(Inherited from SKStream)
Move(Int64)

Seeks to an relative offset in the stream.

(Inherited from SKStream)
OnCreateNew()

Implemented by derived SKAbstractManagedStream types to copy the current stream.

OnDuplicate()

Implemented by derived SKAbstractManagedStream types to duplicate the current stream.

OnDuplicate()

Implemented by derived SKAbstractManagedStream types to duplicate the current stream.

(Inherited from SKAbstractManagedStream)
OnFork()

Implemented by derived SKAbstractManagedStream types to fork the current stream.

OnFork()

Implemented by derived SKAbstractManagedStream types to fork the current stream.

(Inherited from SKAbstractManagedStream)
OnGetLength()

Implemented by derived SKAbstractManagedStream types to return the total length of the stream.

OnGetPosition()

Implemented by derived SKAbstractManagedStream types to get the current position in the stream

OnHasLength()

Implemented by derived SKAbstractManagedStream types to indicate whether this stream can report it's total length.

OnHasPosition()

Implemented by derived SKAbstractManagedStream types to indicate whether this stream can report it's current position.

OnIsAtEnd()

Implemented by derived SKAbstractManagedStream types to indicate whether all the bytes in the stream have been read.

OnMove(Int32)

Implemented by derived SKAbstractManagedStream types to seek to a relative offset.

OnPeek(IntPtr, IntPtr)

Implemented by derived SKAbstractManagedStream types to copy the specified number of bytes into the specified buffer.

OnRead(IntPtr, IntPtr)

Implemented by derived SKAbstractManagedStream types to copy the specified number of bytes into the specified buffer.

OnRewind()

Implemented by derived SKAbstractManagedStream types to rewind the current stream.

OnSeek(IntPtr)

Implemented by derived SKAbstractManagedStream types to seek to an absolute position.

Peek(IntPtr, Int32)

Attempt to peek at size bytes.

(Inherited from SKStream)
Read(Byte[], Int32)

Reads a copy of the specified number of bytes into the provided buffer.

(Inherited from SKStream)
Read(IntPtr, Int32)

Reads a copy of the specified number of bytes into the provided buffer.

(Inherited from SKStream)
ReadBool()

Read a single boolean.

(Inherited from SKStream)
ReadBool(Boolean)

Read a single boolean.

(Inherited from SKStream)
ReadByte()

Read a single byte.

(Inherited from SKStream)
ReadByte(Byte)

Read a single byte.

(Inherited from SKStream)
ReadInt16()

Read a single 16-bit integer.

(Inherited from SKStream)
ReadInt16(Int16)

Read a single 16-bit integer.

(Inherited from SKStream)
ReadInt32()

Read a single 32-bit integer.

(Inherited from SKStream)
ReadInt32(Int32)

Read a single 32-bit integer.

(Inherited from SKStream)
ReadSByte()

Read a single, signed byte.

(Inherited from SKStream)
ReadSByte(SByte)

Read a single, signed byte.

(Inherited from SKStream)
ReadUInt16()

Read a single, unsigned 16-bit integer.

(Inherited from SKStream)
ReadUInt16(UInt16)

Read a single, unsigned 16-bit integer.

(Inherited from SKStream)
ReadUInt32()

Read a single, unsigned 32-bit integer.

(Inherited from SKStream)
ReadUInt32(UInt32)

Read a single, unsigned 32-bit integer.

(Inherited from SKStream)
Rewind()

Rewinds to the beginning of the stream.

(Inherited from SKStream)
Seek(Int32)

Seeks to an absolute position in the stream.

(Inherited from SKStream)
Skip(Int32)

Moves the current position on by the specified number of bytes.

(Inherited from SKStream)
ToMemoryStream()

Copies the contents of this stream into a new memory stream.

Applies to