Hi
Please could someone explain what I'm doing wrong here? This function is meant to load an image from project resources, draw some lines on top of it, then return it. The collection of lines is definitely legit, and the DrawLine command is executed in the loop. But it just returns a blank image, with neither the original image loaded from resources or the lines drawn on top of it.
The saves to temp folder are just debugging code and I'll take them out once it's working.
Many thanks
Joe
Please could someone explain what I'm doing wrong here? This function is meant to load an image from project resources, draw some lines on top of it, then return it. The collection of lines is definitely legit, and the DrawLine command is executed in the loop. But it just returns a blank image, with neither the original image loaded from resources or the lines drawn on top of it.
The saves to temp folder are just debugging code and I'll take them out once it's working.
Many thanks
Joe
VB.NET:
Private Function CreateNewSignature(ByRef sig As Signature, ByRef p As Pen) As Image
Dim retval As Image
Dim g As Graphics = Graphics.FromImage(New Bitmap(IClarity.My.Resources.Resources.sigbackground))
Dim i As Integer = 0
Dim j As Integer = 0
For i = 0 To sig.Glyphs.Count - 1
For j = 0 To sig.Glyphs(i).Lines.Count - 1
g.DrawLine(p, sig.Glyphs(i).Lines(j).StartPoint, sig.Glyphs(i).Lines(j).EndPoint)
Next
Next
Dim imgSignature As New Bitmap(494, 100, g)
g.Dispose()
imgSignature.Save("C:\temp\test.bmp")
imgSignature.Save("C:\temp\test.jpeg")
retval = DirectCast(imgSignature, Image)
Return retval
End Function
VB.NET:
Public Class Line
Public Sub New()
End Sub
Public Sub New(ByVal startPoint As Point, ByVal endPoint As Point)
Me.StartPoint = startPoint
Me.EndPoint = endPoint
End Sub
Public Property StartPoint As Point
Public Property EndPoint As Point
End Class
Public Class Glyph
Public Sub New()
Me.Lines = New List(Of Line)()
End Sub
Public Property Lines As List(Of Line)
End Class
Public Class Signature
Public Sub New()
Me.Glyphs = New List(Of Glyph)()
End Sub
Public Property Glyphs As List(Of Glyph)
End Class