在桌面上将 OpenNetCF GetSignatureEx 转换为位图

发布于 2024-07-19 04:03:36 字数 261 浏览 6 评论 0原文

我有一个在手持设备上运行的 SQLite 数据库,该数据库使用在 Windows Mobile 6.1 下运行的 OpenNetCF 智能设备框架 2.1 捕获签名。 使用 GetSignatureEx 方法从 Signature 控件捕获签名并将其存储在数据库中。

我现在想做的是在桌面上重构签名,但是桌面没有类似的控件。 我查看了数据,它看起来像一堆向量,这解释了为什么数据如此紧凑。

有谁知道如何使用 VB.NET 将数据转换为桌面上的位图。 谢谢。

I have a SQLite database which is running on a handheld which is capturing signatures using OpenNetCF's Smart Device Framework 2.1 running under Windows Mobile 6.1. The signatures are captured from the Signature control using the GetSignatureEx method and stored in the database.

What I want to do now is reconstitute the signatures on the desktop, but the desktop does not have a similar control. I looked at the data and it looks like a bunch of vectors, which explains why the data is so compact.

Does anyone have any idea how I can convert the data into a bitmap on the desktop using VB.NET. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静水深流 2024-07-26 04:03:36

在 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

Found what I wanted on an OpenNetCF forum. The code was originally in C#, but didn't take too long to convert it to VB.NET. This code has been tested on version 2.0 and 2.1 of the OpenNetCF framework, but it will apparently work with version 1.4. Colin

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文