简体   繁体   中英

read local image in wp7

In my app i need to open a local image for cropping. I tried this by setting the path of the image as source to a BitmapImage but it raising an error. How i can read and assign that local image to BitmapImage in WP Mango.

   private WriteableBitmap ReadLocalImage(string Uri)
        {
            StreamResourceInfo sri = null;
            Uri uri = new Uri(Uri, UriKind.Relative);
            sri = Application.GetResourceStream(uri);
            BitmapImage bitmap = new BitmapImage();
            bitmap.CreateOptions = BitmapCreateOptions.None;
            bitmap.SetSource(sri.Stream);
            WriteableBitmap wb = new WriteableBitmap(bitmap);
            return wb;

        }

use this method for reading local image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM