分享

Windows 8 Image

 牛人的尾巴 2015-12-01

Windows 8 Image

(2012-11-26 14:46:54)
标签:

杂谈

方法一:

本地图片库选择图片进行显示:

async private void LoadPictureByPicker()
        {
            FileOpenPicker fileOpen = new FileOpenPicker()
            {
                FileTypeFilter={ ".jpg", ".jpeg", ".png", ".bmp" },
                ViewMode=PickerViewMode.Thumbnail,
                SuggestedStartLocation=PickerLocationId.PicturesLibrary
            };
           bitmapImage = new BitmapImage();
           storageFile = await fileOpen.PickSingleFileAsync();
           if (storageFile != null)
           {
               using (IRandomAccessStream stream = await storageFile.OpenAsync(FileAccessMode.Read))
               {
                   bitmapImage.SetSource(stream);
               }
           }
           this.image.Source = bitmapImage;
        }
 
 
 
方法二:
请求网络URL:
async private void LoadPictrueByUrl()
        {
            var  rass = RandomAccessStreamReference.CreateFromUri(new Uri(url));
            var streamRandom = await rass.OpenReadAsync();
            BitmapImage bitmapImage = new BitmapImage();
            bitmapImage.SetSource(streamRandom);
            this.image.Source = bitmapImage;
        }
 
 
 
 
 
方法三:
显示项目文件图片:
string url = "ms-appx:///Images/flower.jpg";
async private void LoadPictureByNative()
        {
            var  rass = RandomAccessStreamReference.CreateFromUri(new Uri(url));
            streamRandom = await rass.OpenReadAsync();
            var bitmapImage = new BitmapImage();
            bitmapImage.SetSource(streamRandom);
            img.Source = bitmapImage;
        }

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多