123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace fis.media.Helpers
- {
- public class TerminalLiveDataBytes
- {
- private byte[] _terminalData;
- private byte[] _cameraData;
- /// <summary>
- /// Terminal data ARGB
- /// </summary>
- public byte[] TerminalData => _terminalData;
- /// <summary>
- /// Camera data ARGB
- /// </summary>
- public byte[] CameraData => _cameraData;
- /// <summary>
- /// Update terminal and camera data size
- /// </summary>
- /// <param name="terminalBytes"></param>
- public void Update(byte[] source, int terminalBytes, int cameraBytes, int terminalWidth, int terminalHeight, int realWidth)
- {
- if (_terminalData == null)
- {
- _terminalData = new byte[terminalBytes];
- }
- else if (terminalBytes != _terminalData.Length)
- {
- Array.Resize(ref _terminalData, terminalBytes);
- }
- Parallel.For(0, terminalHeight, row =>
- {
- Array.Copy(source, row * realWidth * 4, _terminalData, row * terminalWidth * 4, terminalWidth * 4);
- });
- if (_cameraData == null)
- {
- _cameraData = new byte[cameraBytes];
- }
- else if (cameraBytes != _cameraData.Length)
- {
- Array.Resize(ref _cameraData, cameraBytes);
- }
- if (realWidth > 1920)//Workaround fix ,due to TX will change 1920 to 1936
- {
- Parallel.For(0, 160, row =>
- {
- Array.Copy(source, terminalHeight * realWidth * 4 + row * realWidth * 4, _cameraData, row * 1920 * 4, 1920 * 4);
- });
- }
- else
- {
- Array.Copy(source, realWidth * terminalHeight * 4, _cameraData, 0, cameraBytes);
- }
- }
- }
- }
|