在图像上创建专色点 [英] Creating spot point on image

查看:80
本文介绍了在图像上创建专色点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个用于学习和练习目的的项目..



在图片框中加载图形并在图像上添加一些点。



我的问题是如何删除一个点。



例如..

on我第一次点击鼠标在图像上添加一个点。这里x = 104和y = 108

我的第二次鼠标点击从图像中删除一个点。这里x = 104和y = 108



I am working on a project for study and practise purpose..

load graphic in picture box and add some spot points on image.

my question is how to remove a spot point.

for example..
on my first mouse click add a spot point on image. here x=104 and y=108
on my second mouse click remove a spot point from image. here x=104 and y=108

int x=0;
int y=0;
private void picturebox1_MouseClick(object sender, MouseEventArgs e)
        {
            x = e.X;
            y = e.Y;
            drawPoint();
            ridges++;
            lblttlRdge.Text = ridges.ToString();
        }

        public void drawPoint()
        {
            Graphics g = Graphics.FromHwnd(imazePicZoom.Handle);
            SolidBrush brush = new SolidBrush(Color.Red);
            
            g.FillEllipse(brush, x, y, 5, 5);
            g.Dispose();
        }





我想绘制一个像点(谷歌地图位置标记)选择类型点标记的点。



我尝试了什么:



i以上尝试过代码但在第二次点击时在图像上添加另一个点



I want draw a spot point like (google map location marker) selected type spot marker.

What I have tried:

i have tried above code but on second click add another spot point on image

推荐答案

在绘制点之前必须保存图像区域,然后在绘制新点之前将其恢复spot point:

You have to save the image area around the point before drawing the spot point and restore it before drawing the new spot point:
// Set points to invalid values to indicate that no spot is visible
int x=-1;
int y=-1;
private void picturebox1_MouseClick(object sender, MouseEventArgs 
{
    // Restore area below previous spot point if not first call
    if (x >= 0 && y >= 0)
        restorePoint();
    x = e.X;
    y = e.Y;
    // Save are below new spot point
    savePoint();
    drawPoint();
    ridges++;
    lblttlRdge.Text = ridges.ToString();
}



两个新功能必须使用中心区域 x y 和圆的直径。


这篇关于在图像上创建专色点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆