Does anyone know how I fill the buffer. This is my first time dealing with buffers and I can't seem to find the answer.
PLEASE HELP
Private Sub mnuSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSave.Click
Dim bmp As New Bitmap(300, 300)
Dim bmpRect As New Rectangle(0, 0, bmp.Width, bmp.Height)
Dim g As Graphics = Graphics.FromImage(bmp)
g.SmoothingMode = SmoothingMode.HighQuality
g.FillRectangle(New Drawing2D.LinearGradientBrush(bmpRect, Color.White, Color.SlateGray, 50), bmpRect)
Dim x, y As Double
For degree As Integer = 0 To 359 Step 15
x = Math.Sin((degree / 180) * Math.PI) * 35 + bmp.Width / 2
y = Math.Cos((degree / 180) * Math.PI) * 35 + bmp.Height / 2
g.DrawEllipse(Pens.Black, New RectangleF(CSng(x) - 50, CSng(y) - 50, 100, 100))
Next
g.DrawString("created by GDI+ &
VB.NET", Font, Brushes.Black, 2, 2)
g.DrawRectangle(Pens.Red, 0, 0, bmp.Width - 1, bmp.Height - 1)
Dim memStrm As New IO.MemoryStream
bmp.Save(memStrm, Imaging.ImageFormat.Jpeg)
Dim buffer() As Byte = memStrm.ToArray()
' connect to the database
Dim SQLConn As SqlConnection = New SqlConnection
Dim strSQl As String = strSQl = "INSERT INTO [Auto] (ItemImage) VALUES (@MyImage)"
SQLConn.ConnectionString = "Data Source=(local);" & _
"Initial Catalog=Justin;" & _
"Integrated Security=SSPI"
Dim MyCommand As New SqlCommand
MyCommand.CommandText = strSQl
MyCommand.Connection = SQLConn
SQLConn.Open()
' Construct INSERT Command
MyCommand.Parameters.Add("@MyImage", SqlDbType.Image, buffer.Length).Value = buffer
MyCommand.ExecuteNonQuery()
SQLConn.Close()
bmp.Dispose()
End Sub