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

    Question

  • 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 error No 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
    Thursday, October 30, 2008 3:05 PM

Answers

  •  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 by Marco Zhou Monday, November 03, 2008 10:53 AM
    Thursday, October 30, 2008 4:49 PM
  • 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 by Marco Zhou Monday, November 03, 2008 10:53 AM
    Thursday, October 30, 2008 5:32 PM

All replies

  •  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 by Marco Zhou Monday, November 03, 2008 10:53 AM
    Thursday, October 30, 2008 4:49 PM
  • 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 by Marco Zhou Monday, November 03, 2008 10:53 AM
    Thursday, October 30, 2008 5:32 PM
  • It is not good idea to store images on local disk. If we want to display the data from stream.

    Musakkhir Sayyed.

    Monday, November 18, 2013 8:22 PM