Skip to main content

ImageConverter Class

Package: GHIElectronics.Endpoint.Devices.Camera
Namespace: GHIElectronics.Endpoint.Devices.Camera

Converts a camera frame between pixel formats. Only JPEG input is supported today.

class ImageConverter: ...

Methods​

Convert(byte[] imageData, int width, int height, PixelFormat inPixelFormat, PixelFormat outPixelFormat)​

@staticmethod
def Convert(imageData: list[int], width: int, height: int, inPixelFormat: PixelFormat, outPixelFormat: PixelFormat) -> list[int]:

Decodes a JPEG frame into the requested pixel format.

ParameterTypeDescription
imageDatabyte[]Raw JPEG bytes. The buffer may be longer than the actual JPEG; the end-of-image marker (FF D9) is located automatically.
widthintDecoded frame width in pixels.
heightintDecoded frame height in pixels.
inPixelFormatPixelFormatMust be PixelFormat.Jpeg; other formats throw System.ArgumentException.
outPixelFormatPixelFormatTarget format: PixelFormat.Jpeg returns the trimmed JPEG, PixelFormat.Rgb888 returns 3 bytes per pixel, PixelFormat.Rgb565 returns 2 bytes per pixel.

Returns byte[]: The converted frame, or null if the input does not start with the JPEG SOI marker (FF D8) or no end-of-image marker is found.