docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ImageEncoder

    A utility for encoding raw pixel data into a variety of formats using the Unity Job System.

    Inheritance
    object
    ImageEncoder
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Perception.GroundTruth.Utilities
    Assembly: Unity.Perception.Runtime.dll
    Syntax
    [MovedFrom("UnityEngine.Perception.GroundTruth")]
    public static class ImageEncoder

    Properties

    encodeImagesAsynchronously

    Whether to encode images in parallel (using the JobSystem), or to synchronously encode images.

    Declaration
    public static bool encodeImagesAsynchronously { get; set; }
    Property Value
    Type Description
    bool

    Methods

    ConvertFormat(ImageEncodingFormat)

    Converts an ImageEncodingFormat enum to a LosslessImageEncodingFormat enum.

    Declaration
    public static LosslessImageEncodingFormat ConvertFormat(ImageEncodingFormat encodingFormat)
    Parameters
    Type Name Description
    ImageEncodingFormat encodingFormat

    The file format value to convert.

    Returns
    Type Description
    LosslessImageEncodingFormat
    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    ConvertFormat(LosslessImageEncodingFormat)

    Converts a LosslessImageEncodingFormat enum to an ImageEncodingFormat enum.

    Declaration
    public static ImageEncodingFormat ConvertFormat(LosslessImageEncodingFormat encodingFormat)
    Parameters
    Type Name Description
    LosslessImageEncodingFormat encodingFormat

    The file format value to convert.

    Returns
    Type Description
    ImageEncodingFormat
    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    EncodeImage<T>(NativeArray<T>, int, int, GraphicsFormat, ImageEncodingFormat, Action<NativeArray<byte>>)

    Encodes raw pixel data asynchronously. The callback assigned to this method however will be executed on the main thread.

    Declaration
    public static void EncodeImage<T>(NativeArray<T> rawImageData, int width, int height, GraphicsFormat graphicsFormat, ImageEncodingFormat encodingFormat, Action<NativeArray<byte>> callback) where T : unmanaged
    Parameters
    Type Name Description
    NativeArray<T> rawImageData

    A native buffer of raw pixel data.

    int width
    int height
    GraphicsFormat graphicsFormat
    ImageEncodingFormat encodingFormat

    The file format to encode the image to (example: JPEG, PNG, etc.)

    Action<NativeArray<byte>> callback

    An action to perform (on the main thread) after the asynchronous encoding job has completed.

    Type Parameters
    Name Description
    T

    Where T is a pixel suitable format for ImageConversion.EncodeNativeArrayToJPG

    EncodeImage<T>(NativeArray<T>, int, int, GraphicsFormat, LosslessImageEncodingFormat, Action<NativeArray<byte>>)

    Encodes raw pixel data asynchronously. The callback assigned to this method however will be executed on the main thread.

    Declaration
    public static void EncodeImage<T>(NativeArray<T> rawImageData, int width, int height, GraphicsFormat graphicsFormat, LosslessImageEncodingFormat encodingFormat, Action<NativeArray<byte>> callback) where T : unmanaged
    Parameters
    Type Name Description
    NativeArray<T> rawImageData

    A native buffer of raw pixel data.

    int width
    int height
    GraphicsFormat graphicsFormat
    LosslessImageEncodingFormat encodingFormat

    The lossless file format to encode the image to (RAW, PNG, or EXR)

    Action<NativeArray<byte>> callback

    An action to perform (on the main thread) after the asynchronous encoding job has completed.

    Type Parameters
    Name Description
    T

    Where T is a pixel suitable format for ImageConversion.EncodeNativeArrayToJPG

    WaitForAllEncodingJobsToComplete()

    Wait for all in flight encoding jobs to complete, along with their callbacks. This API can only be called from the main thread.

    Declaration
    public static void WaitForAllEncodingJobsToComplete()
    Exceptions
    Type Condition
    InvalidOperationException
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)