Search code examples
c#.netsilverlightimagewriteablebitmap

Loading Image in Silverlight


I want to create a WritableBitmap and display a bitmap from stream onto a Image object. How to do that in Silverlight. I am doing the following which is not working.

  Image img = new Image();

  System.IO.Stream stream =  File.OpenRead("1.bmp"); //Getting access permission error

  WriteableBitmap bmp1 = new WriteableBitmap(100, 100);
  bmp1.SetSource(stream);
  //do operations with bmp1 

  img.Source = bmp1;

Solution

  • In Silverlight, file I/O is pretty constrained.

    Check this post

    In Browser Silverlight Application - Client Side File/Directory access