Hello all,
when I run the code bellow first time, all is crispy (picturebox gets bitmap with vector graphics painted on it, it lasts, can be saved to file). However, when I try to load second file (execute the same ReadFile_Click() sub with different vector data), the PictureBox turns BLANK.
I can't figure out, why it works only first time and what should be cleared/disposed/refreshed/etc to get it working...
(code stripped of unnecessary parts):
During execution of PlotAllVectorData(), it is (via few subs) painted onto the picturebox, roughly like this:
I spent a lot of time on it and googling it, still can't figure it out. I'd appriciate your suggestions.
Best regards,
Oak
when I run the code bellow first time, all is crispy (picturebox gets bitmap with vector graphics painted on it, it lasts, can be saved to file). However, when I try to load second file (execute the same ReadFile_Click() sub with different vector data), the PictureBox turns BLANK.
I can't figure out, why it works only first time and what should be cleared/disposed/refreshed/etc to get it working...
(code stripped of unnecessary parts):
Code:
picturebox Code:
- Public Bitmap1 As Bitmap
- Public picture1 As Graphics
-
- Private Sub ReadFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReadFile.Click
- ' CLEARING
- Me.DataGridView1.Rows.Clear()
- 'Me.PictureBox1.Image = Nothing
- picture1 = Nothing
- Bitmap1 = Nothing
- ' INICIALIZATION
- Bitmap1 = New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height)
- picture1 = Graphics.FromImage(Bitmap1)
-
- Call Redraw()
- End Sub
-
- Public Sub Redraw()
- Call ComputeScale()
- Call PlotAllVectorData()
- Me.PictureBox1.Image = Bitmap1
- End Sub
Code:
Me.picture1.DrawLine(objPen,X,Y,X1,Y1)
Best regards,
Oak