首 页 | 新 闻 | Symbian | Android| Windows Mobile | J2ME | 下载中心 | 游戏策划招聘与求职 | 购书指南 | 视频教程
您现在的位置: 开发视界 >> Windows Mobile >> Windows Mobile 开发 >> 正文
Windows Moblie 笔迹图板开发
作者:csdn    文章来源:csdn    更新时间:2008-4-7 15:27:07

这是应一个网友的问题而做的一个小程序,可以保存为位图,我觉得还是有一定的参考价值的,所以就把相关代码贴了出来。


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); 
            }
        }
    }
}

相关文章:
没有相关文章
 

站点地图 | 加入收藏 | 联系站长 | 广告服务 |
QQ:280529124  Tel:0592-8271361 辽ICP备05021703号