.NET Framework Bookmark and Share   
 index > Windows Presentation Foundation (WPF) > WPF - Load image from stream - Error No Imaging component found
 

WPF - Load image from stream - Error No Imaging component found

I'm trying to load a image at runtime from memory stream. The stream itself is from byte array obtained from C++ DLL of a DICOM image. I'm trying to set the stream to the bitmap object & then load the image to the image control. See code snippet below

I always get the errorNo imaging component suitable to complete this operation was found.

BitmapImage bi = new BitmapImage();
bi.BeginInit();
Stream ms = new MemoryStream(abyteArray0);
ms.Seek(0, SeekOrigin.Begin);
bi.StreamSource = ms;
bi.EndInit();
img.Source = bi;

Please help!!!

Thanks,
Rajeev
Rajeev_SISL_BV
You can use this:

using (MemoryStream stream = new MemoryStream(abyteArray0))
{
image.Source =
BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
}

The field image should be of type Image.

  • Marked As Answer byMarco Zhou Monday, November 03, 2008 10:53 AM
  •  
Mariano O. Rodriguez
This usually happens when the image is corrupted. So test if the image is good, first save the image on the disk. If it turns out to be a legitimate image, then we can look for other options to fix this.
Research and Development Imageright Inc. http://krishnabhargav.blogspot.com
  • Marked As Answer byMarco Zhou Monday, November 03, 2008 10:53 AM
  •  
KrishnaBhargava
You can use this:

using (MemoryStream stream = new MemoryStream(abyteArray0))
{
image.Source =
BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
}

The field image should be of type Image.

  • Marked As Answer byMarco Zhou Monday, November 03, 2008 10:53 AM
  •  
Mariano O. Rodriguez
This usually happens when the image is corrupted. So test if the image is good, first save the image on the disk. If it turns out to be a legitimate image, then we can look for other options to fix this.
Research and Development Imageright Inc. http://krishnabhargav.blogspot.com
  • Marked As Answer byMarco Zhou Monday, November 03, 2008 10:53 AM
  •  
KrishnaBhargava

You can use google to search for other answers

Custom Search

More Threads

• Set Culture Info in App.xaml
• Data Binding Radio Button Group
• Button with Image as Icon and Text with It - Styles not getting applied
• C1DateEdit control in WPF application
• How to display XML dyamically in ListView with a GridView.
• Binding to a collection + one other item for a "None" selection?
• How to navigate from XBAP to an html page - before the first page has loaded.
• Custom 3D controls, using Viewport2DVisual3D
• Inherited Form in WPF
• Is Deep Zoom available for wpf user?