获取图像的两点之间的像素数 [英] Get number of pixels between two points in an Image
问题描述
我的工作,需要的两点是在图像中的水平之间的像素数的项目。我在Windows应用程序的形式这样做。
I am working on a project which requires a number of pixels between two points which are horizontal in an image. I am doing this in a windows application form.
基本上当上某个点的用户点击图像,然后在其他点那么他应该在一些形式的水平距离的像素。
Basically when a user clicks on one point in image and then on other point then he should get horizontal distance in form on number of pixels.
我没有得到任何想法去做。
请帮助。
I am not getting any idea to do it. please help.
推荐答案
假设你的图像是使用任何控制从控制<下降显示/ code>,那么你将有机会获得
Control.MouseClick
事件(的链接)。
Assuming your image is displayed using any control descended from Control
then you will have access to the Control.MouseClick
event (link).
这事件使用 MouseEventArgs
(链接一>),它有一个属性的X.
This event uses MouseEventArgs
(link), which has a property X.
应该是从这一点非常明确。
Should be pretty clear from that point.
编辑:加入这个非常简单的例子:
Added this very simple example:
private int? x1;
private void MyImageControl_MouseClick(object sender, MouseEventArgs e)
{
if (x1.HasValue)
{
MessageBox.Show("Difference of " + Math.Abs(e.X - x1.Value).ToString());
x1 = null;
}
else
{
x1 = e.X;
}
}
这篇关于获取图像的两点之间的像素数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!