How to Convert Byte Array to BitmapSource in C# for Silverlight-VBForums
Results 1 to 1 of 1

Thread: How to Convert Byte Array to BitmapSource in C# for Silverlight

Hybrid View

  1. #1

    Thread Starter
    Fanatic Member vuyiswamb's Avatar
    Join Date
    Jan 2007
    Location
    South Africa
    Posts
    799

    How to Convert Byte Array to BitmapSource in C# for Silverlight

    Good Day All

    I have a Generic function that in my Static Class. i have this Class in Silverlight
    Code:
        public static BitmapSource LoadImage(Byte[] imageBytes)
            {
                BitmapImage bmpImage = new BitmapImage();
                MemoryStream mystream = new MemoryStream(imageBytes);
                bmpImage.SetSource(mystream);
                return bmpImage;
            }
    Now this looked fine for me until i had to bind an Image in Silverlight like this

    PhotoHolder.Source =GenericMethods.LoadImage(model.imbPhoto);

    The Images i have in the Database are Supported by silverlight they are jpg type.

    and the Elelment that i am binding to look like this in Silverlight

    Code:
       <Image x:Name="PhotoHolder" Height="98" Width="102" OpacityMask="Black"  Canvas.Left="141" Canvas.Top="30">
                    <Image.Effect>
                        <DropShadowEffect/>
                    </Image.Effect>
                </Image>
    so if i bind i get this Error

    Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

    Thanks
    Last edited by vuyiswamb; May 26th, 2011 at 05:17 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.