docs.unity3d.com
    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
    Namespace: UnityEngine.Perception.GroundTruth
    Syntax
    public static class ImageEncoder : object

    Fields

    encodeImagesAsynchronously

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

    Declaration
    public static bool encodeImagesAsynchronously
    Field Value
    Type Description
    Boolean

    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

    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

    EncodeImage<T>(NativeArray<T>, Int32, Int32, 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 : struct
    Parameters
    Type Name Description
    NativeArray<T> rawImageData

    A native buffer of raw pixel data.

    Int32 width
    Int32 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

    EncodeImage<T>(NativeArray<T>, Int32, Int32, 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 : struct
    Parameters
    Type Name Description
    NativeArray<T> rawImageData

    A native buffer of raw pixel data.

    Int32 width
    Int32 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

    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()
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023