Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.6.28
|
Leadtools Namespace > RasterImage Class > GetYUVData Method : GetYUVData(RasterYUVFormat,IntPtr,Int64) Method |
public long GetYUVData( RasterYUVFormat yuvFormat, IntPtr buffer, long bufferCount )
'Declaration
Public Overloads Function GetYUVData( _ ByVal yuvFormat As RasterYUVFormat, _ ByVal buffer As IntPtr, _ ByVal bufferCount As Long _ ) As Long
'Usage
Dim instance As RasterImage Dim yuvFormat As RasterYUVFormat Dim buffer As IntPtr Dim bufferCount As Long Dim value As Long value = instance.GetYUVData(yuvFormat, buffer, bufferCount)
public long GetYUVData( RasterYUVFormat yuvFormat, IntPtr buffer, long bufferCount )
function Leadtools.RasterImage.GetYUVData(RasterYUVFormat,IntPtr,Int64)( yuvFormat , buffer , bufferCount )
public: int64 GetYUVData( RasterYUVFormat yuvFormat, IntPtr buffer, int64 bufferCount )
The user is responsible for allocating and freeing the YUV buffer when it is no longer needed.
The buffer should be large enough to store the data for the whole image. If the buffer is not large enough to store all the requested data, the method will throw and exception.
Note that in each case, the function ignores the ViewPerspective. So the YUV data will match the view perspective in the image. In other words, if the image's view perspective is BottomLeft, the YUV data you retrieve in the YUV buffer will be flipped. In most cases, you will want the YUV buffer to be correct side up, so you will want ViewPerspective to be TopLeft. You can use ChangeViewPerspective to make the bitmap be the correct ViewPerspective.
The YUV data will be in studio YUV format, which means the Y values will range from 16 to 235 and U, V values will range from 16 to 240. The Y values are unsigned, while U, V values are offset by 0x80. In other words, a value of 0x80 for U corresponds to a U value of 0 and a value of 0x7F corresponds to a U value of -1.
If you do not know the expected size of the YUV buffer, you can call the function twice, as follows: long dataSize = image.GetYUVData(RasterYUVFormat.NV12, IntPtr.Zero, 0L); Byte[] dataBuffer = new byte[size]; image.GetYUVData(RasterYUVFormat.YV12, yuvBuffer2, 0, yuvBuffer2.Length);