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

2 posts, 0 answers
  1. Bill Anderson
    Bill Anderson avatar
    6 posts
    Member since:
    Feb 2010

    Posted 01 Aug 2011 Link to this post

    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.
  2. Bill Anderson
    Bill Anderson avatar
    6 posts
    Member since:
    Feb 2010

    Posted 02 Aug 2011 Link to this post

    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

     

  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top