使用JQuery的图像实现 [英] Image implementation in using JQuery
本文介绍了使用JQuery的图像实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通过WCF,我可以获取1个图像对象(字节流),但是之后如何在客户端(JQuery)中将其转换为图像以在屏幕上显示图像.以下是我的代码-
Through WCF I am able to get 1 image object(stream of bytes) but after that how can I convert it into image in client side(JQuery) to show the image on screen. Following is my code -
public Image GetEmployeePhoto(string EmpID)
{
string strbase64String = string.Empty;
try
{
if (EmpID != String.Empty)
{
TravelService.ImageService1.FileManager obj = new TravelService.ImageService1.FileManager();
strbase64String = obj.retrievefile(EmpID).ToString();
}
if (strbase64String != string.Empty)
{
System.Drawing.Image empImage = ConvertBase64StringToImage(strbase64String);
return empImage;
// System.Windows.Media.ImageSource imageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
// imgEmpPhoto.Source = imageSource;
}
}
catch (Exception ex)
{
//ShowErrorMessage("Employee Photo");
}
return null;
}
public System.Drawing.Image ConvertBase64StringToImage(string objbase64String)
{
try
{
byte[] imageBytes = Convert.FromBase64String(objbase64String);
System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBytes, 0, imageBytes.Length);
ms.Write(imageBytes, 0, imageBytes.Length);
System.Drawing.Image objImage = System.Drawing.Image.FromStream(ms, true);
return objImage;
}
catch (Exception ex)
{
throw ex;
}
}
请帮帮我.非常感谢.
Please help me out. Thanks a lot.
推荐答案
请检查以下示例是否相同:
此处 [
Please check this example for same:
here[^]
这篇关于使用JQuery的图像实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文