while (rev_data_udp != null && Thread.CurrentThread.ThreadState.Equals(ThreadState.Running))
{
try
{
byte[] buf = rev_data_udp.Receive(ref remoteHost);
//以下代码用于取出当前这个数据包对应的屏幕坐标数据
byte[] info = new byte[50];
Array.Copy(buf, 0, info, 0, 50);
string info_data_str = Encoding.UTF8.GetString(info);
int start_pos=info_data_str.IndexOf("#x_1:")+5;
int end_pos=info_data_str.IndexOf("y_1:");
int point_x = Convert.ToInt32(info_data_str.Substring(start_pos, end_pos - start_pos));
start_pos = end_pos + 4;
end_pos = info_data_str.IndexOf("x_2:");
int point_y = Convert.ToInt32(info_data_str.Substring(start_pos, end_pos - start_pos));
Point left_top_point = new Point(point_x, point_y);
start_pos = end_pos + 4;
end_pos = info_data_str.IndexOf("y_2:");
point_x = Convert.ToInt32(info_data_str.Substring(start_pos, end_pos - start_pos));
start_pos = end_pos + 4;
end_pos = info_data_str.IndexOf("#####");
point_y = Convert.ToInt32(info_data_str.Substring(start_pos, end_pos - start_pos));
Point right_bottom_point = new Point(point_x, point_y);
byte[] image_bytes = new byte[buf.Length-50];
Array.Copy(buf, 50, image_bytes, 0, image_bytes.Length);
Image data = Screen.BytesToImg(image_bytes);
if (null != display_rev_data_func)
{
display_rev_data_func(left_top_point,right_bottom_point,data);
}
}
|