Class JpegEncoder
Managed wrapper around the libturbojpeg native library that encodes raw pixel data to JPEG.
Used by CaptureImageEncoder when USIM_USE_BUILTIN_JPG_ENCODER is not defined.
Inherited Members
Namespace: Global Namespace
Assembly: Unity.SimulationPro.Capture.dll
Syntax
public class JpegEncoder
Methods
Decode(byte[], ref int, ref int)
Decodes a JPEG byte array into raw RGBA pixel data using libturbojpeg.
Declaration
public static byte[] Decode(byte[] jpg, ref int width, ref int height)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | jpg | The JPEG-compressed image bytes to decode. |
| int | width | Receives the decoded image width in pixels. |
| int | height | Receives the decoded image height in pixels. |
Returns
| Type | Description |
|---|---|
| byte[] | A byte array containing the decoded image in TJPF_RGBA format (4 bytes per pixel). |
Encode(byte[], int, int, int, GraphicsFormat, int, Flags)
Encodes a raw pixel buffer as a JPEG image using libturbojpeg.
Declaration
public static byte[] Encode(byte[] raw, int width, int height, int pixelSize, GraphicsFormat textureFormat, int quality = 75, JpegEncoder.Flags flags = Flags.TJ_BOTTOMUP)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | raw | Raw pixel bytes to encode. |
| int | width | Image width in pixels. |
| int | height | Image height in pixels. |
| int | pixelSize | Bytes per pixel (e.g. 1 for grayscale, 3 for RGB, 4 for RGBA). |
| GraphicsFormat | textureFormat | The GraphicsFormat of the source data, used to choose the libturbojpeg pixel format. |
| int | quality | JPEG quality factor (1–100). Defaults to 75. |
| JpegEncoder.Flags | flags | libturbojpeg compression flags. Defaults to TJ_BOTTOMUP for bottom-up row order. |
Returns
| Type | Description |
|---|---|
| byte[] | Encoded JPEG bytes, or |