M
michael hilton
Hello all-
I am developing an application that will take serial data from a
compass on a boat, and display it to the screen, like a compass. To
do this i need to draw a line on top of a bitmap, and have it refresh
at ~ 2 times a sec. I am new to vb.NET, it was working fine in eVB.
Here is the code that i have. if i call the fromimage on the bmp on i
want to update, compassBox.image, then the lines are not cleared, just
added on top of all the other lines. this will work for about 30 sec,
then there is an out of memory exception. I belive it is becuase i am
initializing a new bitmap every time, but if i call the dispose() on
temp then the image will not update.
Any help is greatly appreciated. I need to either find a way to clear
the old lines off the initial bitmap, so there is only one line at a
time, or find a way to clean up the memory from the tempBmp, so as to
not cause an exception.
Thanks so much for any help!!
Michael Hilton
''''Code
tempBmp = New Bitmap(PictureBox3.Image)
myGraphics = Graphics.FromImage(tempBmp )
myGraphics.DrawLine(New
System.Drawing.Pen(System.Drawing.Color.LimeGreen), 100, 100, xcoord,
ycoord)
CompassBox.Image = tempBmp
myGraphics.Dispose()
'tempBmp.Dispose() if i uncomment this line, it will not update the
display
''''/Code
An unhandled exception of type 'System.OutOfMemoryException' occurred
in System.Drawing.dll
Additional information: OutOfMemoryException
I am developing an application that will take serial data from a
compass on a boat, and display it to the screen, like a compass. To
do this i need to draw a line on top of a bitmap, and have it refresh
at ~ 2 times a sec. I am new to vb.NET, it was working fine in eVB.
Here is the code that i have. if i call the fromimage on the bmp on i
want to update, compassBox.image, then the lines are not cleared, just
added on top of all the other lines. this will work for about 30 sec,
then there is an out of memory exception. I belive it is becuase i am
initializing a new bitmap every time, but if i call the dispose() on
temp then the image will not update.
Any help is greatly appreciated. I need to either find a way to clear
the old lines off the initial bitmap, so there is only one line at a
time, or find a way to clean up the memory from the tempBmp, so as to
not cause an exception.
Thanks so much for any help!!
Michael Hilton
''''Code
tempBmp = New Bitmap(PictureBox3.Image)
myGraphics = Graphics.FromImage(tempBmp )
myGraphics.DrawLine(New
System.Drawing.Pen(System.Drawing.Color.LimeGreen), 100, 100, xcoord,
ycoord)
CompassBox.Image = tempBmp
myGraphics.Dispose()
'tempBmp.Dispose() if i uncomment this line, it will not update the
display
''''/Code
An unhandled exception of type 'System.OutOfMemoryException' occurred
in System.Drawing.dll
Additional information: OutOfMemoryException