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

retrieving image into an image editor.

2 Answers 146 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Edd
Top achievements
Rank 1
Edd asked on 04 Jan 2015, 10:00 PM
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();
  sda.Fill(dt);
 
  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);


Thanks

2 Answers, 1 is accepted

Sort by
0
Marbry
Top achievements
Rank 1
answered on 09 Jan 2015, 08:30 PM
Just went through this, you'll have to save it into a location on the file system under the application.
0
Vessy
Telerik team
answered on 12 Jan 2015, 01:54 PM
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

Regards,
Vessy
Telerik
 

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.

 
Tags
ImageEditor
Asked by
Edd
Top achievements
Rank 1
Answers by
Marbry
Top achievements
Rank 1
Vessy
Telerik team
Share this question
or