C# 如何得到图片上某个像素点的坐标
C#.net中图片上有个红色亮点,背景全黑,怎么得到这个红点的坐标!比如图片是640×480的。GetPixelColor函数行不行?...
C#.net 中图片上有个红色亮点,背景全黑,怎么得到这个红点的坐标!比如图片是640×480的。GetPixelColor函数行不行?
展开
2个回答
展开全部
当然不行了,直接获得该点的XY坐标,之后计算出实际坐标
给你个例子
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
float loc_X = 0;
float loc_Y = 0;
float loc_Fy = 0;
loc_X = e.Location.X ;
loc_Y = e.Location.Y;
//判断是否1、10---1小时 8小时
DateTime dt_HM=new DateTime ();
DateTime last_Time = DateTime.Now;
if (combJD_SJKD.Text =="10")
{
dt_HM = Convert.ToDateTime (DateTime.Now.AddHours(-7).ToString("yyyy-MM-dd HH") + ":10");
//loc_X = ((loc_X - 50)* 2)/3;
loc_X = (((loc_X - 50) * 43) / (pub_lastX - 50)) * 10;
}
else
{
dt_HM = Convert.ToDateTime (DateTime.Now.AddHours(-1).ToString("yyyy-MM-dd HH:mm"));
//loc_X = (loc_X - 50) / 12;
loc_X = ((loc_X - 50) * 58) / (pub_lastX-50);
}
//Y轴取整换算成实际坐标轴
loc_Fy = (panel1.Height -30)-loc_Y;
//1个刻度有多少格
float Y_GESHU = ((panel1.Height - 30) - pub_lastY) / 60;
//loc_Fy = loc_Fy/7;
//loc_Fy = loc_Fy / 8 + 3;
loc_Y =(int )( (loc_Fy)/Y_GESHU );
loc_Y = (int)(loc_Y - (loc_Y / 10));
//X轴换算成实际坐标轴
dt_HM = dt_HM.AddMinutes(loc_X);
//提取查询的日期、时间 并确定比例因子
int scale=1;
scale = scale * pub_addscale;
loc_Y = loc_Y * scale;
lab_ZT.Text = "通行人数为:" + Convert.ToString(loc_Y) + "人 此时刻值为" + dt_HM.ToString() ;
}
给你个例子
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
float loc_X = 0;
float loc_Y = 0;
float loc_Fy = 0;
loc_X = e.Location.X ;
loc_Y = e.Location.Y;
//判断是否1、10---1小时 8小时
DateTime dt_HM=new DateTime ();
DateTime last_Time = DateTime.Now;
if (combJD_SJKD.Text =="10")
{
dt_HM = Convert.ToDateTime (DateTime.Now.AddHours(-7).ToString("yyyy-MM-dd HH") + ":10");
//loc_X = ((loc_X - 50)* 2)/3;
loc_X = (((loc_X - 50) * 43) / (pub_lastX - 50)) * 10;
}
else
{
dt_HM = Convert.ToDateTime (DateTime.Now.AddHours(-1).ToString("yyyy-MM-dd HH:mm"));
//loc_X = (loc_X - 50) / 12;
loc_X = ((loc_X - 50) * 58) / (pub_lastX-50);
}
//Y轴取整换算成实际坐标轴
loc_Fy = (panel1.Height -30)-loc_Y;
//1个刻度有多少格
float Y_GESHU = ((panel1.Height - 30) - pub_lastY) / 60;
//loc_Fy = loc_Fy/7;
//loc_Fy = loc_Fy / 8 + 3;
loc_Y =(int )( (loc_Fy)/Y_GESHU );
loc_Y = (int)(loc_Y - (loc_Y / 10));
//X轴换算成实际坐标轴
dt_HM = dt_HM.AddMinutes(loc_X);
//提取查询的日期、时间 并确定比例因子
int scale=1;
scale = scale * pub_addscale;
loc_Y = loc_Y * scale;
lab_ZT.Text = "通行人数为:" + Convert.ToString(loc_Y) + "人 此时刻值为" + dt_HM.ToString() ;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询