在桌面上将OpenNetCF GetSignatureEx转换为位图 [英] Converting OpenNetCF GetSignatureEx to Bitmap on Desktop

查看:50
本文介绍了在桌面上将OpenNetCF GetSignatureEx转换为位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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

推荐答案

在OpenNetCF论坛上找到了我想要的东西.该代码最初是用C#编写的,但花了很长时间才将其转换为VB.NET.该代码已经在OpenNetCF框架的2.0版和2.1版上进行了测试,但是显然可以在1.4版上使用.科林

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

这篇关于在桌面上将OpenNetCF GetSignatureEx转换为位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆