Inserting Image

2 posts, 0 answers
  1. Brian
    Brian avatar
    24 posts
    Member since:
    Apr 2008

    Posted 29 Sep 2014 Link to this post

    Hi,

    Your example shows how to insert jpg image from file:

    Using stream As Stream = Me.GetResourceStream("Telerik_logo.jpg")
    editor.DrawImage(stream, ImageFormat.Jpeg, New Size(118, 28))
    End Using

    I would like to insert image from .NET Image class variable. The images are stored in Base64 format in a database.

    Could you provide a code snippet for that?

    Regards,
    Brian
  2. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 29 Sep 2014 Link to this post

    Hello Brian,

    You can convert the Base64 string to memory stream (see the code below) and use it in the DrawImage method.

    Dim imageBytes As Byte() = Convert.FromBase64String(base64String)
    Dim ms As New MemoryStream(imageBytes, 0, imageBytes.Length)

    Note that currently only JPEG images are supported.

    Hope this helps.


    Regards,
    Kammen
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top