Search Results for

    Show / Hide Table of Contents

    Class StreamHelper

    Inheritance
    System.Object
    StreamHelper
    Namespace: IronPPT.Models.Extensions
    Assembly: IronPPT.dll
    Syntax
    public static class StreamHelper : Object

    When an image arrives as a stream, StreamHelper identifies its format and turns it into a Base64 string for embedding. The static helper adds extension methods to the common stream types, so detecting a picture's type and serializing its bytes happen directly on the stream rather than through a separate utility call.

    GetImageType reads a stream and returns the detected ImageType, with overloads for FileStream, MemoryStream, and the base Stream, so the same call works whether the image came from disk or memory. ToBase64 returns the stream's contents as a Base64 string, with overloads for FileStream and Stream, ready to place into markup or a data URL. Because all five are extension methods, you call them on the stream you already hold (stream.GetImageType()), which keeps image handling inline. Reach for GetImageType before adding a picture to confirm its format, and for ToBase64 when an image needs an inline textual form instead of a file reference.

    ImageType type = imageStream.GetImageType();
    string base64 = imageStream.ToBase64();

    The manage image how-to covers working with pictures on a slide, and the add image example places an image into a presentation.

    Methods

    GetImageType(FileStream)

    Declaration
    public static ImageType GetImageType(this FileStream stream)
    Parameters
    Type Name Description
    System.IO.FileStream stream
    Returns
    Type Description
    ImageType

    GetImageType(MemoryStream)

    Declaration
    public static ImageType GetImageType(this MemoryStream stream)
    Parameters
    Type Name Description
    System.IO.MemoryStream stream
    Returns
    Type Description
    ImageType

    GetImageType(Stream)

    Declaration
    public static ImageType GetImageType(this Stream stream)
    Parameters
    Type Name Description
    System.IO.Stream stream
    Returns
    Type Description
    ImageType

    ToBase64(FileStream)

    Declaration
    public static string ToBase64(this FileStream stream)
    Parameters
    Type Name Description
    System.IO.FileStream stream
    Returns
    Type Description
    System.String

    ToBase64(Stream)

    Declaration
    public static string ToBase64(this Stream stream)
    Parameters
    Type Name Description
    System.IO.Stream stream
    Returns
    Type Description
    System.String
    ☀
    ☾
    Downloads
    • Download with NuGet
    • Start for Free
    In This Article
    Back to top
    Install with NuGet