C API Unity API
Unity API Reference (Version 10.22.5)
Image Class Reference

Representation of an image, typically returned by the CameraDevice. More...

Public Member Functions

 Image (ImageDescription description, IntPtr data)
 
void CopyBufferToTexture (Texture2D texture)
 The whole buffer (i.e. BufferWidth x BufferHeight) is copied to the texture. Width, height and format of texture will be updated to fit the input image. More...
 
void CopyToTexture (Texture2D texture2D)
 Copies the image into the given texture. Width and height of texture will be updated to fit the input image. The image data is converted to the format of the texture. Only grayscale, RGB24 and RGBA32 are supported. Only the image portion defined by Width and Height is copied to the texture, not the whole buffer. More...
 
void CopyToTexture (Texture2D texture2D, bool flipY)
 Copies the image into the given texture. Width and height of texture will be updated to fit the input image. The image data is converted to the format of the texture. Only grayscale, RGB24 and RGBA32 are supported. Only the image portion defined by Width and Height is copied to the texture, not the whole buffer. More...
 
void Resize (ImageDescription description)
 Resizing an image deletes any existing image data More...
 

Static Public Member Functions

static bool IsNullOrEmpty (Image image)
 Checks whether the image is null or if it's contains any data More...
 

Public Attributes

int BufferHeight => Description.BufferHeight
 The height (number of rows) of the underlying pixel buffer. More...
 
int BufferWidth => Description.BufferWidth
 The width (number of columns) of the underlying pixel buffer. More...
 
int Height => Description.Height
 The height of the image in pixels. Note that the pixel buffer can be higher than this. More...
 
IntPtr PixelBufferPtr => mData
 The pointer to the pixel buffer More...
 
PixelFormat PixelFormat => Description.PixelFormat
 The pixel format of the image More...
 
int Stride => Description.Stride
 The number of bytes between the start of a pixel row and the start of the next More...
 
int Width => Description.Width
 The width of the image in pixels. Note that the pixel buffer can be wider than this. More...
 

Properties

ImageDescription Description [get]
 
byte [] Pixels [get]
 Get pixel data of the image More...
 

Detailed Description

Representation of an image, typically returned by the CameraDevice.

The image's pixel buffer may have a different size than expected based on the values of Width and Height.

Constructor & Destructor Documentation

◆ Image()

Image ( ImageDescription  description,
IntPtr  data 
)
inline

Member Function Documentation

◆ CopyBufferToTexture()

void CopyBufferToTexture ( Texture2D  texture)
inline

The whole buffer (i.e. BufferWidth x BufferHeight) is copied to the texture. Width, height and format of texture will be updated to fit the input image.

◆ CopyToTexture() [1/2]

void CopyToTexture ( Texture2D  texture2D)
inline

Copies the image into the given texture. Width and height of texture will be updated to fit the input image. The image data is converted to the format of the texture. Only grayscale, RGB24 and RGBA32 are supported. Only the image portion defined by Width and Height is copied to the texture, not the whole buffer.

◆ CopyToTexture() [2/2]

void CopyToTexture ( Texture2D  texture2D,
bool  flipY 
)
inline

Copies the image into the given texture. Width and height of texture will be updated to fit the input image. The image data is converted to the format of the texture. Only grayscale, RGB24 and RGBA32 are supported. Only the image portion defined by Width and Height is copied to the texture, not the whole buffer.

Parameters
texture2Doutput texture
flipYwhether the image should be flipped in y-direction

◆ IsNullOrEmpty()

static bool IsNullOrEmpty ( Image  image)
inlinestatic

Checks whether the image is null or if it's contains any data

Parameters
image
Returns

◆ Resize()

void Resize ( ImageDescription  description)
inline

Resizing an image deletes any existing image data

Member Data Documentation

◆ BufferHeight

int BufferHeight => Description.BufferHeight

The height (number of rows) of the underlying pixel buffer.

◆ BufferWidth

int BufferWidth => Description.BufferWidth

The width (number of columns) of the underlying pixel buffer.

◆ Height

int Height => Description.Height

The height of the image in pixels. Note that the pixel buffer can be higher than this.

◆ PixelBufferPtr

IntPtr PixelBufferPtr => mData

The pointer to the pixel buffer

◆ PixelFormat

PixelFormat PixelFormat => Description.PixelFormat

The pixel format of the image

◆ Stride

int Stride => Description.Stride

The number of bytes between the start of a pixel row and the start of the next

◆ Width

int Width => Description.Width

The width of the image in pixels. Note that the pixel buffer can be wider than this.

Property Documentation

◆ Description

ImageDescription Description
get

◆ Pixels

byte [] Pixels
get

Get pixel data of the image