csharp: winform using Microsoft.Ink(Tablet PC API) create Signature image

复制代码
  1 /*
  2 下載:
  3 //Microsoft Windows XP Tablet PC Edition 2005 Recognizer Pack http://www.microsoft.com/zh-cn/download/details.aspx?id=1601
  4 //Microsoft Windows XP Tablet PC Edition Software Development Kit 1.7  http://www.microsoft.com/en-us/download/details.aspx?id=20039
  5  * Microsoft Speech Platform - Software Development Kit (SDK) (Version 11) http://www.microsoft.com/en-us/download/details.aspx?id=27226
  6  * Microsoft SDKs http://msdn.microsoft.com/en-us/dd299405.aspx
  7  *Microsoft.Ink 命名空间  http://msdn.microsoft.com/zh-cn/library/microsoft.ink%28v=vs.90%29.aspx
  8  * 
  9  *  安裝的文件在://Program Files\Microsoft Tablet PC Platform SDK\Include\Microsoft.Ink.dll
 10  *  在Windows XP sp3 環境下測試
 11  */
 12 
 13 using System;
 14 using System.Collections.Generic;
 15 using System.ComponentModel;
 16 using System.Data;
 17 using System.Drawing;
 18 using System.Linq;
 19 using System.Text;
 20 using System.Windows.Forms;
 21 using System.IO;
 22 using Microsoft.Ink; //引用:Micosoft Tablet PC
 23 
 24 
 25 
 26 
 27 
 28 namespace ChineseCalenderGeovinDu
 29 {
 30     /// <summary>
 31     /// 20120914
 32     /// 塗聚文
 33     /// 捷為工作室
 34     /// 締友計算機信息技術有限公司
 35     /// </summary>
 36     public partial class TabletPCForm : Form
 37     {
 38 
 39         InkOverlay inkOverlay;
 40         InkPicture InkPicture1 = new InkPicture();
 41 
 42         /// <summary>
 43         /// 
 44         /// </summary>
 45         public TabletPCForm()
 46         {
 47             InitializeComponent();
 48         }
 49         /// <summary>
 50         /// 
 51         /// </summary>
 52         /// <param name="sender"></param>
 53         /// <param name="e"></param>
 54         private void TabletPCForm_Load(object sender, EventArgs e)
 55         {
 56             inkOverlay = new InkOverlay();
 57             inkOverlay.Handle = this.pictureBox1.Handle;// this.Handle;//整個窗體
 58             inkOverlay.Enabled = true;
 59 
 60         }
 61        
 62         /// <summary>
 63         /// 保存圖片
 64         /// </summary>
 65         /// <param name="sender"></param>
 66         /// <param name="e"></param>
 67         private void buttonSave_Click(object sender, EventArgs e)
 68         {
 69             SaveFileDialog sfd = new SaveFileDialog();
 70             sfd.Filter = "GIF IMAGES(*.gif)|*.gif";
 71             if (sfd.ShowDialog() == DialogResult.OK)
 72             {
 73                 txtpath.Text = sfd.FileName;
 74                 FileStream gifFile;
 75                 byte[] fortifiedGif = null;
 76                 // open the file for writing
 77                 gifFile = File.OpenWrite(txtpath.Text);
 78                 // Generate the fortified GIF represenation of the ink
 79                 fortifiedGif = inkOverlay.Ink.Save(PersistenceFormat.Gif);
 80                 // Write and close the gif file
 81                 gifFile.Write(fortifiedGif, 0, fortifiedGif.Length);
 82                 gifFile.Close();
 83                 this.pictureBox2.Image = Image.FromFile(sfd.FileName);
 84             }
 85         }
 86 
 87        
 88         /// <summary>
 89         /// 清除
 90         /// </summary>
 91         /// <param name="sender"></param>
 92         /// <param name="e"></param>
 93         private void buttonClear_Click(object sender, EventArgs e)
 94         {
 95             inkOverlay.Enabled = false;
 96             inkOverlay.Ink.DeleteStrokes();
 97             this.pictureBox1.Invalidate() ;
 98             this.pictureBox2.Invalidate();
 99             inkOverlay.Enabled = true;
100         }
101 
102 
103 
104 
105 
106 
107 
108 
109 
110 
111     }
112 
113 }
复制代码

 

 

posted @   ®Geovin Du Dream Park™  阅读(1065)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
历史上的今天:
2010-09-14 AJAX Framework四个框架:AJAX Control Toolkit,MagicAjax.NET,Anthem.NET,Ajax.NET Professional
2009-09-14 aspx net.2.0 C#获取IP,URL,浏览器,操作系统
< 2012年9月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 1 2 3 4 5 6
点击右上角即可分享
微信分享提示