11-15-2007, 12:36
|
lidds
Joined on 10-31-2007
Posts 13
|
Saving and restoring image to SQL Server...
|
 
 
|
|
|
Prior to utilising Leadtools I used a standard picturebox control. What my application does is capture the screen graphics in the following:
Private MyBitMap As Bitmap
I then have converted to Leadtools rasterimage type which works fine and display the image fine in the rasterviewer (code below):
Dim myCovertImg As Leadtools.RasterImage = New Leadtools.RasterImage(MyBitMap)
Me.rasterViewer.Image = myCovertImg
My problem now comes when trying to save the image. The field within the database is of image type. Before I convert the image in the picturebox into a system.io.memorystream and saved this to the database as follows:
'Read image into byte
' save image to stream...
Dim clsStream1 As New System.IO.MemoryStream
' Todo
Me.picBox.Image.Save(clsStream1, System.Drawing.Imaging.ImageFormat.Jpeg)
' read bytes from stream...
Dim emptyByte As Byte = Nothing
Dim b As Byte() = DirectCast(Array.CreateInstance(GetType(Byte), clsStream1.Length), Byte())
clsStream1.Position = 0
clsStream1.Read(b, 0, b.Length)
clsStream1.Close()
Dim myInsertCmd As New OleDb.OleDbCommand("spInsertComm")
myInsertCmd.CommandType = CommandType.StoredProcedure
OleDb.OleDbParameter("@commImage", OleDb.OleDbType.LongVarBinary, b.Length, ParameterDirection.Input, False, emptyByte, emptyByte, "commImage", DataRowVersion.Current, b))
However I am now strugling to save the same using rasterImage control. Could you please give an example code of how to do this?
Also I am adding annotation to the image, using Leadtools functionality, what is the best way for me to save not only the image but also the annotation to the database? Are you able to supply a code example?
Sorry for asking for code examples but I have a deadline in the next day and I have been trying to sort this out for a while now.
Thank you in advance
Simon
|
|
|
|
|
Report
|
|
|
|