none
问题,关于WebClient 下载 zip的显示图片 RRS feed

  • 问题

  • Code Snippet
    WebClient webClient = new WebClient();webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);webClient.OpenReadAsync(new Uri("myimages.zip", UriKind.Relative));

     

    Code Snippet

     void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { MediaElement mediaElement = new MediaElement(); if ((e.Error == null) && (e.Cancelled == false)) { StreamResourceInfo zipResourceInfo = new StreamResourceInfo(e.Result, null); StreamResourceInfo imageResourceInfo = Application.GetResourceStream(zipResourceInfo, new Uri("image1.jpg", UriKind.Relative)); mediaElement.SetSource(imageResourceInfo.Stream); } }

     

    按照SDK上面的方法,zip只能下载视频文件啊,要是图片用BitmapImage,但是 BitmapImage.SetSource的这个方法在SDK上面也没有说明,我要下载一个zip,动态载入zip里面的一个图片,在显示到画布上要怎么做呀?
    2008年5月6日 15:59
    版主

答案

  •  

    Uri uri = new Uri(relativeUriString, UriKind.RelativeOrAbsolute);
                StreamResourceInfo zipPackageSri = new StreamResourceInfo(zipPackageStream, null);
                StreamResourceInfo imageSri = Application.GetResourceStream(zipPackageSri, uri);

                // Convert the stream to an Image
                BitmapImage bi = new BitmapImage();
                bi.SetSource(imageSri.Stream);
              

    呵呵!

    加油!
    2008年5月7日 1:42
    版主

全部回复

  •  

    Uri uri = new Uri(relativeUriString, UriKind.RelativeOrAbsolute);
                StreamResourceInfo zipPackageSri = new StreamResourceInfo(zipPackageStream, null);
                StreamResourceInfo imageSri = Application.GetResourceStream(zipPackageSri, uri);

                // Convert the stream to an Image
                BitmapImage bi = new BitmapImage();
                bi.SetSource(imageSri.Stream);
              

    呵呵!

    加油!
    2008年5月7日 1:42
    版主
  • 来到公司一弄就都通了,谢谢天使,今天回家我再看看为啥有那种诡异问题

    2008年5月7日 1:50
    版主