retrieving image into an image editor.

3 posts, 0 answers
  1. Edd
    Edd avatar
    37 posts
    Member since:
    Jan 2013

    Posted 04 Jan 2015 Link to this post

    Hi All, 
    I am using the below code to retrieve an varbinary image from a database. Is it possible to display the image into an image editor.
    Any idea or sample code 
    SqlConnection conn = new SqlConnection(strconnection);
      SqlDataAdapter sda = new SqlDataAdapter("select Front_Image,Rear_Image from Transactions", conn);
      DataTable dt = new DataTable();
      foreach (DataRow row in dt.Rows)
          //Get the byte array from image file
          byte[] imgBytes = (byte[])row["Front_Image"];
          //If you want convert to a bitmap file
          TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
          Bitmap MyBitmap = (Bitmap)tc.ConvertFrom(imgBytes);
          string imgString = Convert.ToBase64String(imgBytes);
          //Set the source with data:image/bmp
          Front_img.Src = String.Format("data:image/Bmp;base64,{0}\"", imgString);

  2. Marbry
    Marbry avatar
    122 posts
    Member since:
    Aug 2012

    Posted 09 Jan 2015 Link to this post

    Just went through this, you'll have to save it into a location on the file system under the application.
  3. DevCraft R3 2016 release webinar banner
  4. Vessy
    Vessy avatar
    1349 posts

    Posted 12 Jan 2015 Link to this post

    Hello Edd,

    As mentioned by Marby, the default ImageEditor's behavior is to work with files from the file system. If you want to use the control to edit images stored in a data base you will need a custom storage content provider. A sample implementation of a  DataBase provider implemented by us is available in the following live demo: Using Custom Content Provider


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top