The code I have is in c# wpf, but I need it in asp c#. Can anyone pls. help? I appreciate it. thanks!
public ImageSource ConvertImage(byte[] imageParam)
{
try
{
MemoryStream memoryStream = new MemoryStream(imageParam);
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(memoryStream);
IntPtr bitmapPtr = bitmap.GetHbitmap();
System.Windows.Controls.Image image = new System.Windows.Controls.Image();
System.Windows.Media.ImageSource imageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
bitmapPtr,
IntPtr.Zero,
System.Windows.Int32Rect.Empty,
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
bitmap.Dispose();
memoryStream.Close();
return imageSource;
}
catch (Exception)
{
return new BitmapImage(new Uri("Images/CompanyLogo.jpg", UriKind.Relative));
}
}
I can get the image source in binary file by using stored proc. But the main concern is how do I convert it to string or an object so I can use it as Image source for an image??

New Topic/Question
Reply




MultiQuote


|