-
Notifications
You must be signed in to change notification settings - Fork 8
YuvImage
ReferenceType edited this page Mar 12, 2025
·
2 revisions
The YuvImage
class represents a YUV420 planar image. It handles memory allocation and provides methods to access image data efficiently.
The YuvImage
class is designed to manage YUV420 images using unmanaged memory for performance efficiency. It supports creating instances with allocated memory or referencing existing image data.
- Represents YUV420 planar format.
- Handles both allocated and referenced unmanaged memory.
- Provides a method to retrieve the raw byte data.
- Implements
IDisposable
for proper memory management. - Only disposes unmanaged memory if its allocated by this class(owns).
Constructor | Description |
---|---|
YuvImage(int width, int height) |
Allocates unmanaged memory for a YUV420 image. |
YuvImage(IntPtr data, int width, int height) |
References an existing unmanaged YUV420 image. |
YuvImage(IntPtr data, int width, int height, int Ystride, int UVstride) |
References an existing YUV420 image with custom strides. |
Property | Type | Description |
---|---|---|
Width |
int |
The image width in pixels. |
Height |
int |
The image height in pixels. |
strideY |
int |
The number of bytes per row in the Y plane. |
strideUV |
int |
The number of bytes per row in the U and V planes.(one of them, both strides assumed the same) |
ImageBytes |
IntPtr |
Pointer to the image data in unmanaged memory. |
Method | Return Type | Description |
---|---|---|
ToYUVImagePointer() |
YUVImagePointer |
Creates a pointer structure for direct access to Y, U, and V channels. |
GetBytes() |
byte[] |
Returns the raw image data as a byte array. |
Dispose() |
void |
Releases unmanaged memory. |
YuvImage img = new YuvImage(1920, 1080);
IntPtr existingData = GetNativeYUVData();
YuvImage img = new YuvImage(existingData, 1920, 1080);
byte[] imageData = img.GetBytes();