簡體   English   中英

在桌面上將OpenNetCF GetSignatureEx轉換為位圖

[英]Converting OpenNetCF GetSignatureEx to Bitmap on Desktop

我有一個運行在手持設備上的SQLite數據庫,該手持設備正在使用在Windows Mobile 6.1下運行的OpenNetCF的智能設備框架2.1來捕獲簽名。 使用GetSignatureEx方法從Signature控件捕獲簽名,並將其存儲在數據庫中。

我現在想做的是在桌面上重構簽名,但是桌面沒有類似的控件。 我查看了數據,它看起來像一堆矢量,這解釋了為什么數據如此緊湊。

有誰知道如何使用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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM