/
Image.cs
115 lines (106 loc) · 5.03 KB
/
Image.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
//////////////////////////////////////////////////
///// AUTOGENERATED MESSAGE DEFINITION /////
//////////////////////////////////////////////////
///// DO NOT MODIFY BY HAND! /////
//////////////////////////////////////////////////
namespace ROS_CS
{
namespace sensor_msgs
{
public class Image : ROS_CS.Core.BaseMessage
{
public readonly string typeID = "Image";
public readonly string md5sum = "060021388200f6f0f447d0fcd9c64743";
public std_msgs.Header header;
public System.UInt32 height;
public System.UInt32 width;
public string encoding;
public System.Byte is_bigendian;
public System.UInt32 step;
public List<System.Byte> data;
public Image ()
{
header = new std_msgs.Header();
height = 0;
width = 0;
encoding = "";
is_bigendian = 0;
step = 0;
data = new List<System.Byte>();
}
public override string ToString ()
{
return ROS_CS.Core.PrettyPrinter.PrettyPrint(ToStringRaw());
}
public override string ToStringRaw ()
{
string string_rep = typeID + ":\n";
string_rep += header.ToStringRaw() + "\n";
string_rep += "height: " + Convert.ToString(height) + "\n";
string_rep += "width: " + Convert.ToString(width) + "\n";
string_rep += "encoding: " + encoding + "\n";
string_rep += "is_bigendian: " + Convert.ToString(is_bigendian) + "\n";
string_rep += "step: " + Convert.ToString(step) + "\n";
string_rep += "data:\n[";
foreach (System.Byte element in data)
{
string_rep += " " + Convert.ToString(element);
}
string_rep += "]\n\n";
return string_rep;
}
public override void Serialize(MemoryStream stream)
{
header.Serialize(stream);
System.Byte[] height_bytes = BitConverter.GetBytes(height);
stream.Write(height_bytes, 0, height_bytes.Length);
System.Byte[] width_bytes = BitConverter.GetBytes(width);
stream.Write(width_bytes, 0, width_bytes.Length);
System.Byte[] encoding_bytes = System.Text.Encoding.UTF8.GetBytes(encoding);
System.Byte[] encoding_len_bytes = BitConverter.GetBytes((System.UInt32)encoding_bytes.Length);
stream.Write(encoding_len_bytes, 0, encoding_len_bytes.Length);
stream.Write(encoding_bytes, 0, encoding_bytes.Length);
System.Byte[] is_bigendian_bytes = new System.Byte[] {is_bigendian};
stream.Write(is_bigendian_bytes, 0, is_bigendian_bytes.Length);
System.Byte[] step_bytes = BitConverter.GetBytes(step);
stream.Write(step_bytes, 0, step_bytes.Length);
System.Byte[] data_bytes = data.ToArray();
System.Byte[] data_len_bytes = BitConverter.GetBytes((System.UInt32)data_bytes.Length);
stream.Write(data_len_bytes, 0, data_len_bytes.Length);
stream.Write(data_bytes, 0, data_bytes.Length);
}
public override int Deserialize(System.Byte[] serialized)
{
return Deserialize(serialized, 0);
}
public override int Deserialize(System.Byte[] serialized, int startIndex)
{
int curIndex = startIndex;
curIndex += header.Deserialize(serialized, curIndex);
height = BitConverter.ToUInt32(serialized, curIndex);
curIndex += BitConverter.GetBytes(height).Length;
width = BitConverter.ToUInt32(serialized, curIndex);
curIndex += BitConverter.GetBytes(width).Length;
System.UInt32 encoding_len = BitConverter.ToUInt32(serialized, curIndex);
curIndex += BitConverter.GetBytes(encoding_len).Length;
encoding = System.Text.Encoding.UTF8.GetString(serialized, curIndex, (int)encoding_len);
curIndex += (int)encoding_len;
is_bigendian = serialized[curIndex];
curIndex++;
step = BitConverter.ToUInt32(serialized, curIndex);
curIndex += BitConverter.GetBytes(step).Length;
System.UInt32 data_len = BitConverter.ToUInt32(serialized, curIndex);
curIndex += BitConverter.GetBytes(data_len).Length;
System.Byte[] temp = new System.Byte[data_len];
Array.Copy(serialized, curIndex, temp, 0, data_len);
data = temp.ToList();
curIndex += (int)data_len;
return (curIndex - startIndex);
}
}
}
}