Vb.net 将OpenNetCF GetSignatureEx转换为桌面上的位图
我有一个运行在手持设备上的SQLite数据库,它使用WindowsMobile 6.1下运行的OpenNetCF智能设备框架2.1捕获签名。使用GetSignatureEx方法从签名控件捕获签名并存储在数据库中 我现在想做的是在桌面上重建签名,但是桌面没有类似的控件。我看了数据,它看起来像一堆向量,这解释了为什么数据如此紧凑Vb.net 将OpenNetCF GetSignatureEx转换为桌面上的位图,vb.net,compact-framework,opennetcf,smart-device-framework,Vb.net,Compact Framework,Opennetcf,Smart Device Framework,我有一个运行在手持设备上的SQLite数据库,它使用WindowsMobile 6.1下运行的OpenNetCF智能设备框架2.1捕获签名。使用GetSignatureEx方法从签名控件捕获签名并存储在数据库中 我现在想做的是在桌面上重建签名,但是桌面没有类似的控件。我看了数据,它看起来像一堆向量,这解释了为什么数据如此紧凑 有人知道我如何使用VB.NET将数据转换成桌面上的位图吗。谢谢。在OpenNetCF论坛上找到了我想要的。该代码最初是用C编写的,但没有花太长时间就将其转换为VB.NET。
有人知道我如何使用VB.NET将数据转换成桌面上的位图吗。谢谢。在OpenNetCF论坛上找到了我想要的。该代码最初是用C编写的,但没有花太长时间就将其转换为VB.NET。这段代码已经在OpenNetCF框架的2.0和2.1版上进行了测试,但显然它可以在1.4版上使用。科林
Public Function GetSignature(ByVal arrsig As Byte(), ByVal backcolor As System.Drawing.Color)
Dim pic As System.Windows.Forms.PictureBox
Dim word As Integer
Dim lngIndex As Integer
Dim lngPointsToRead As Integer = 0
Dim lngCurrX As Integer = -1
Dim lngCurrY As Integer = -1
Dim lngPrevX As Integer = -1
Dim lngPrevY As Integer = -1
Dim lngWidth As Integer = 1
Dim lngHeight As Integer
Dim bit As New System.Drawing.Bitmap(1, 1)
Dim g As Graphics = Graphics.FromImage(bit)
pic = New picturebox()
Dim blackpen As New Pen(Color.Black)
If arrsig.Length < 3 Then
Return Nothing
End If
word = arrsig(0)
word = word + System.Convert.ToInt32(arrsig(1)) * 256
lngWidth = word
word = arrsig(2)
word = word + System.Convert.ToInt32(arrsig(3)) * 256
lngHeight = word
bit = New Bitmap(lngWidth, lngHeight)
g = Graphics.FromImage(bit)
g.Clear(backcolor)
lngIndex = 4
While (True)
If (lngIndex >= arrsig.Length) Then
Exit While
End If
If (lngPointsToRead = 0) Then
word = arrsig(lngIndex)
lngIndex = lngIndex + 1
word = word + System.Convert.ToInt32(arrsig(lngIndex)) * 256
lngPointsToRead = word
lngPrevX = -1
lngPrevY = -1
Else
If (lngCurrX = -1) Then
word = arrsig(lngIndex)
If (lngWidth > 255) Then
lngIndex = lngIndex + 1
word = word + System.Convert.ToInt32(arrsig(lngIndex)) * 256
End If
lngCurrX = word
ElseIf (lngCurrY = -1) Then
word = arrsig(lngIndex)
If (lngHeight > 255) Then
lngIndex = lngIndex + 1
word = word + System.Convert.ToInt32(arrsig(lngIndex)) * 256
End If
lngCurrY = word
lngPointsToRead = lngPointsToRead - 1
If (lngPrevX <> -1) Then
g.DrawLine(blackpen, lngPrevX, lngPrevY, lngCurrX, lngCurrY)
End If
lngPrevX = lngCurrX
lngPrevY = lngCurrY
lngCurrX = -1
lngCurrY = -1
End If
End If
lngIndex = lngIndex + 1
End While
pic.Image = bit
Return pic.Image
End Function