내가 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
출처
2009-07-03 20:58:59
CDM