Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ArtNet.ArtNet
- {
- static class Helper
- {
- static public void WriteString(ref byte[] Data, uint Offset, string Text, uint Length)
- {
- int i;
- for (i = 0; i < Length; i++)
- {
- if (i < Text.Length)
- {
- Data[Offset + i] = Convert.ToByte(Text[i]);
- }
- else
- {
- Data[Offset + i] = 0;
- }
- }
- // Пследний символ всегда 0
- Data[Offset + Length - 1] = 0;
- }
- static public void WriteArray(ref byte[] Data, uint Offset, byte[] Source, uint Length)
- {
- int i;
- for (i = 0; i < Length; i++)
- {
- if (i < Source.Length)
- {
- Data[Offset + i] = Source[i];
- }
- else
- {
- Data[Offset + i] = 0;
- }
- }
- }
- // LB HB
- static public void WriteUInt16(ref byte[] Data, uint Offset, int Value)
- {
- Data[Offset + 0] = Convert.ToByte(Value & 0xFF); // LSB
- Data[Offset + 1] = Convert.ToByte((Value >> 8) & 0xFF); // MSB
- }
- // HB LB
- static public void WriteUInt16BE(ref byte[] Data, uint Offset, int Value)
- {
- Data[Offset + 1] = Convert.ToByte(Value & 0xFF); // LSB
- Data[Offset + 0] = Convert.ToByte((Value >> 8) & 0xFF); // MSB
- }
- static public void WriteByte(ref byte[] Data, uint Offset, byte Value)
- {
- Data[Offset] = Value;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement