←Select platform

RasterYUVFormat Enumeration

Summary
Used with SetYUVData and GetYUVData to specify the YUV data format.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public enum RasterYUVFormat 
typedef NS_ENUM(NSInteger, LTRasterYUVFormat) { 
 LTRasterYUVFormatYV12,  
 LTRasterYUVFormatNV12,  
 LTRasterYUVFormatNV21,  
 LTRasterYUVFormatYUY2 
}; 
public final class RasterYUVFormat 
    extends java.lang.Enum<RasterYUVFormat> 
public enum class RasterYUVFormat   
class RasterYUVFormat(Enum): 
   YV12 = 0 
   NV12 = 1 
   NV21 = 2 
   YUY2 = 3 
Members
ValueMemberDescription
0YV12 Planar Y, U, V data using 4:1:1 (aka 4:2:0) subsampling. The U and V planes are half the width and height of the Y plane. The Y plane is followed immediately by the U (Cb) plane, which is followed immediately by the V (Cr) plane. The YUV data is 12 bits/pixel (each 2x2 pixels are described by 6 bytes).
The image width and height must be multiple of 2.
The size of the YUV data is width * height * 3 / 2.
1NV12 A Y plane followed by interleaved plane of UV data. There are half as many U and V samples as Y samples in both width and height. In other words, for each 2x2 square of Y pixels, there is only one corresponding U, V pair. The YUV data is 12 bits/pixel (each 2x2 pixels are described by 6 bytes).
The image width and height must be multiple of 2.
The size of the YUV data is width * height * 3 / 2.
2NV21 A Y plane followed by interleaved plane of VU data. Similar to NV12 data, except that the order of UV samples is reversed. The YUV data is 12 bits/pixel (each 2x2 pixels are described by 6 bytes).
The image width and height must be multiple of 2.
The size of the YUV data is width * height * 3 / 2.
3YUY2 Interleaved 4:2:2 YUYV data. Each two horizontal pixels have the same U and V values. The YUV data is 16 bits/pixel (each 2 pixels are described by 4 bytes).
The image width must be a multiple of 2.
The size of the YUV data is width * height * 2.
|
Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Core; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Dicom; 
using Leadtools.Drawing; 
using Leadtools.Controls; 
using Leadtools.Svg; 
 
 
public static void SetYUVDataExample() 
{ 
	string fileName = Path.Combine(LEAD_VARS.ImagesDir, "nv21.bin"); 
	using (RasterCodecs codecs = new RasterCodecs()) 
	{ 
		using (RasterImage image = new RasterImage(RasterMemoryFlags.Conventional, 1920, 1080, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, null, null, 0)) 
		{ 
			using (FileStream yuvFile = File.OpenRead(fileName)) 
			{ 
				int size = 1920 * 1080 * 3 / 2; 
 
				Byte[] yuvBuffer = new Byte[size]; 
				yuvFile.Read(yuvBuffer, 0, size); 
 
				image.SetYUVData(yuvBuffer, 0, size, RasterYUVFormat.NV21); 
 
				codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "nv21_net.jpg"), RasterImageFormat.Jpeg, 0); 
 
				Byte[] yuvBuffer2 = new byte[size]; 
				image.GetYUVData(RasterYUVFormat.YV12, yuvBuffer2, 0, yuvBuffer2.Length); 
 
				image.SetYUVData(yuvBuffer2, 0, yuvBuffer2.Length, RasterYUVFormat.YV12); 
 
				codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "nv21_net_2.jpg"), RasterImageFormat.Jpeg, 0); 
 
				System.Diagnostics.Debug.WriteLine("Save succeeded"); 
			} 
		} 
	} 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

See Also

Reference

Leadtools Namespace

Help Version 22.0.2023.5.16
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.