winCE签名

本文介绍了一个使用C#实现的手绘跟踪系统,该系统能够捕捉并显示用户在面板上的绘制动作,并支持清除画布及保存为位图文件的功能。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace HandImage
{
    
public partial class frmTest : Form
    {
        List
<Points> HandTrack=new List<Points>();
        
public Graphics pb_Graphics;
        Bitmap pb_BMP 
= new Bitmap(239,235);

        
int index = 0;    //第几笔
        public frmTest()
        {
            InitializeComponent();
        }

        
private void pnlBar_MouseMove(object sender, MouseEventArgs e)
        {
            HandTrack[index].PT.Add(
new Point(e.X, e.Y));
            pnlBar.Refresh();
        }

        
private void pnlBar_Paint(object sender, PaintEventArgs e)
        {
            pb_Graphics 
= Graphics.FromImage((System.Drawing.Image)pb_BMP);
            pb_Graphics.Clear(pnlBar.BackColor);
            
foreach(Points item in  HandTrack)
            {
                pb_Graphics.DrawLines(
new Pen(Color.Black), item.PT.ToArray());  
            }
            e.Graphics.DrawImage(pb_BMP, 
00);
            pb_Graphics.Dispose(); 
        }

        
class Points
        {
            
public List<Point> PT=new List<Point>();
        }

        
private void btnClear_Click(object sender, EventArgs e)
        {
            index 
= 0;
            HandTrack 
= new List<Points>();
            pnlBar.Refresh();  
        }

        
private void pnlBar_MouseUp(object sender, MouseEventArgs e)
        {
            index
++;
        }

        
private void pnlBar_MouseDown(object sender, MouseEventArgs e)
        {
            HandTrack.Add(
new Points());
            HandTrack[index].PT.Add(
new Point(e.X, e.Y));
            pnlBar.Refresh();  
        }

        
private void btnSave_Click(object sender, EventArgs e)
        {
            dlgSaveFile.Filter 
= "位图(*.bmp)|*.bmp"
            
if (dlgSaveFile.ShowDialog() == DialogResult.OK)
            {
                
string strFile = dlgSaveFile.FileName;
                pb_BMP.Save(strFile, System.Drawing.Imaging.ImageFormat.Bmp); 
            }
        }
    }
}
 
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值