Updates the image data using the YUV data from an input buffer. The YUV data is converted to grayscale/BGR before being set in the RasterImage.
public void SetYUVData(
byte[] buffer,
int bufferIndex,
int bufferCount,
Leadtools.RasterYUVFormat yuvFormat
)
Public Overloads Sub SetYUVData( _
ByVal buffer() As Byte, _
ByVal bufferIndex As Integer, _
ByVal bufferCount As Integer, _
ByVal yuvFormat As Leadtools.RasterYUVFormat _
)
public:
void SetYUVData(
array<byte>^ buffer,
int bufferIndex,
int bufferCount,
Leadtools.RasterYUVFormat yuvFormat
)
buffer
Buffer that contains the YUV data.
bufferIndex
The zero-based index into the buffer where the set operation should start.
bufferCount
Size of the data buffer pointed to by buffer. If this value is incorrect, this method will throw an exception.
yuvFormat
Specifies the YUV data format.
This function is designed to be used mainly for use in mobile imaging to facilitate filling a BITMAPHANDLE structure using live frames from the mobile device's camera.
The function ignores the image's view perspective, so it must match the orientation of the YUV buffer. In most cases, the YUV buffer is top-to-bottom, so the ViewPerspective should be TopLeft. If the YUV buffer is flipped, the ViewPerspective should be BottomLeft, so it will be automatically flipped before saving or painting.
The YUV data should contain studio video YUV, with Y values ranging from 16 to 235 and U,V values ranging from 16 to 240. Values outside this range are clipped: values below 16 will be considered as if they were 16. Y values above 235 will be clipped to 235, U/V values above 240 will be clipped to 240.
The only supported bits per pixel are 8, 24 and 32.
Gets the image data in YUV format. The format is indicated by yuvFormat. The data is returned as a byte array. The data starts at index 0 and is equal to the size of the array.
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 LeadtoolsExamples.Common;
using Leadtools.Svg;
public static void SetYUVDataExample()
{
string fileName = Path.Combine(ImagesPath.Path, "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(ImagesPath.Path, "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(ImagesPath.Path, "nv21_net_2.jpg"), RasterImageFormat.Jpeg, 0);
System.Diagnostics.Debug.WriteLine("Save succeeded");
}
}
}
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Controls
Imports Leadtools.Dicom
Imports Leadtools.Drawing
Imports Leadtools.Svg
Public Shared Sub SetYUVDataExample()
Dim fileName As String = Path.Combine(Common.ImagesPath.Path, "nv21.bin")
Using codecs As New RasterCodecs
Using image As New RasterImage(RasterMemoryFlags.Conventional, 1920, 1080, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, Nothing, Nothing, 0)
Using yuvFile As FileStream = File.OpenRead(fileName)
Dim size As Integer = CInt(1920 * 1080 * 3 / 2)
Dim yuvBuffer As Byte() = New Byte(size) {}
yuvFile.Read(yuvBuffer, 0, size)
image.SetYUVData(yuvBuffer, 0, size, RasterYUVFormat.NV21)
codecs.Save(image, Path.Combine(Common.ImagesPath.Path, "nv21_net.jpg"), RasterImageFormat.Jpeg, 0)
Dim yuvBuffer2 As Byte() = New Byte(size) {}
image.GetYUVData(RasterYUVFormat.YV12, yuvBuffer2, 0, yuvBuffer2.Length)
image.SetYUVData(yuvBuffer2, 0, yuvBuffer2.Length, RasterYUVFormat.YV12)
codecs.Save(image, Path.Combine(Common.ImagesPath.Path, "nv21_net_2.jpg"), RasterImageFormat.Jpeg, 0)
System.Diagnostics.Debug.WriteLine("Save succeeded")
End Using
End Using
End Using
End Sub
Products |
Support |
Feedback: SetYUVData(Byte[],Int32,Int32,RasterYUVFormat) Method - Leadtools |
Introduction |
Help Version 19.0.2017.6.19
|
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.