J
Johngeh
Guest
I have a program that takes a screenshot of the computer screen. I want to add a small line graph to the image to show some performance metrics.
I can take the screenshot and add text to it. The following code should add an image of a line chart to the upper right hand corner. The code runs but the resulting file does not contain the image of the chart I am looking for.
I can display the chart in the program with no problem so I know I can create it and it exists.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim sImageFile As String = ""
Dim newimage As Bitmap
newimage = screenCapture()
Dim gr As Graphics = Graphics.FromImage(newimage)
Dim myFontLabels As New Font("Arial", 48, FontStyle.Regular)
Dim myBrushLabels As New SolidBrush(Color.Red)
Dim graphImage As New Bitmap(Chart1.Width, Chart1.Height)
Chart1.DrawToBitmap(graphImage, New Rectangle(Chart1.Location, Chart1.Size))
gr.DrawString(Format(Now(), "M/d/yy H:mm"), myFontLabels, myBrushLabels, newimage.Size.Width - 500, newimage.Size.Height - 100) '# last 2 number are X and Y coords.
gr.DrawImage(graphImage, New Point(newimage.Size.Width - 500, 50))
sImageFile = "c:\temp\Test_" + Format(Now(), "MMddyyyy_Hmmss") + ".jpg"
newimage.Save(sImageFile, System.Drawing.Imaging.ImageFormat.Jpeg)
End Sub
Any ideas?
Thanks for your help.
John
Continue reading...
I can take the screenshot and add text to it. The following code should add an image of a line chart to the upper right hand corner. The code runs but the resulting file does not contain the image of the chart I am looking for.
I can display the chart in the program with no problem so I know I can create it and it exists.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim sImageFile As String = ""
Dim newimage As Bitmap
newimage = screenCapture()
Dim gr As Graphics = Graphics.FromImage(newimage)
Dim myFontLabels As New Font("Arial", 48, FontStyle.Regular)
Dim myBrushLabels As New SolidBrush(Color.Red)
Dim graphImage As New Bitmap(Chart1.Width, Chart1.Height)
Chart1.DrawToBitmap(graphImage, New Rectangle(Chart1.Location, Chart1.Size))
gr.DrawString(Format(Now(), "M/d/yy H:mm"), myFontLabels, myBrushLabels, newimage.Size.Width - 500, newimage.Size.Height - 100) '# last 2 number are X and Y coords.
gr.DrawImage(graphImage, New Point(newimage.Size.Width - 500, 50))
sImageFile = "c:\temp\Test_" + Format(Now(), "MMddyyyy_Hmmss") + ".jpg"
newimage.Save(sImageFile, System.Drawing.Imaging.ImageFormat.Jpeg)
End Sub
Any ideas?
Thanks for your help.
John
Continue reading...