Hi,
I want to update a bmp in memory to a picture box on mouse move or a button click say in vb.net 2008.
I create a .bmp in file and used following code
Public Sub create_bmp() 'Create a new bitmap
Using Bmp As New Bitmap(PictureBox1.Width, PictureBox1.Height, Imaging.PixelFormat.Format32bppPArgb)
'Set the resolution to 200 DPI
Bmp.SetResolution(200, 200)
'Create a graphics object from the bitmap
Using G = Graphics.FromImage(Bmp)
'Paint the canvas white
G.Clear(Color.White)
'Set various modes to higher quality
G.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
G.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
G.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
'Create a font
Using F As New Font("Arial", 8)
'Create a brush
Using B As New SolidBrush(Color.Black)
'Draw some text
G.DrawString("XY", F, B, 20, 20)
End Using
End Using
End Using
'Save the file as a bmp
Bmp.Save("f:\test123.bmp", Imaging.ImageFormat.Bmp)
Dim bmp1 As Bitmap = Bitmap.FromFile("f:\test123.bmp")
PictureBox1.Image = bmp1
End Using
End Sub
This works first time ok but when i call above routine again I found err A generic error occurred in GDI+.
on line Bmp.Save("f:\test123.bmp", Imaging.ImageFormat.Bmp)
what goes wrong? plz help..:dispirited:
I want to update a bmp in memory to a picture box on mouse move or a button click say in vb.net 2008.
I create a .bmp in file and used following code
Public Sub create_bmp() 'Create a new bitmap
Using Bmp As New Bitmap(PictureBox1.Width, PictureBox1.Height, Imaging.PixelFormat.Format32bppPArgb)
'Set the resolution to 200 DPI
Bmp.SetResolution(200, 200)
'Create a graphics object from the bitmap
Using G = Graphics.FromImage(Bmp)
'Paint the canvas white
G.Clear(Color.White)
'Set various modes to higher quality
G.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
G.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
G.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
'Create a font
Using F As New Font("Arial", 8)
'Create a brush
Using B As New SolidBrush(Color.Black)
'Draw some text
G.DrawString("XY", F, B, 20, 20)
End Using
End Using
End Using
'Save the file as a bmp
Bmp.Save("f:\test123.bmp", Imaging.ImageFormat.Bmp)
Dim bmp1 As Bitmap = Bitmap.FromFile("f:\test123.bmp")
PictureBox1.Image = bmp1
End Using
End Sub
This works first time ok but when i call above routine again I found err A generic error occurred in GDI+.
on line Bmp.Save("f:\test123.bmp", Imaging.ImageFormat.Bmp)
what goes wrong? plz help..:dispirited: