This is a migrated thread and some comments may be shown as answers.

capturing changed image and storing as an image data type column in SQL database

1 Answer 93 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Bill Anderson
Top achievements
Rank 1
Bill Anderson asked on 01 Aug 2011, 02:45 PM
How do I capture the changed image during the ImageChanged event and process it to an image file for uploading and storing as an image column in the SQL database ??

I've tried to capture args.image in the ImageChanged event and save it as an image field, i.e. as Byte()... but I keep getting an error that I cannot convert args.Image to a System.Drawing.Image ?????

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Bill Anderson
Top achievements
Rank 1
answered on 02 Aug 2011, 03:23 PM
I played around with it yesterday myself and came up with the attached code, using  args.image.image as my changed image source along with some older code   It seemed to work OK as well. 

 

 

 

Protected Sub RadImageEditor1_ImageChanged(ByVal sender As Object, ByVal args As Telerik.Web.UI.ImageEditorEventArgs) Handles RadImageEditor1.ImageChanged

 

 

 

Dim imgData() As Byte = ImageToByte(args.Image.Image)

 

Session(

 

"imgDataByte") = imgData

 

 

 

End Sub

 

 

 

Public Shared Function ImageToByte(ByVal img As Image) As Byte()

 

 

 

Dim imgStream As MemoryStream = New MemoryStream()

 

img.Save(imgStream, System.Drawing.Imaging.

 

ImageFormat.Png)

 

imgStream.Close()

 

 

Dim byteArray As Byte() = imgStream.ToArray()

 

imgStream.Dispose()

 

 

Return byteArray

 

 

 

End Function

 

Tags
ImageEditor
Asked by
Bill Anderson
Top achievements
Rank 1
Answers by
Bill Anderson
Top achievements
Rank 1
Share this question
or