zoukankan      html  css  js  c++  java
  • WP7备注(8)(WebClient读取图片)

    远程图片数据申请:

    XNA:

    protected override void LoadContent()
    {
    spriteBatch = new SpriteBatch(GraphicsDevice);
    WebClient webClient = new WebClient();
    webClient.OpenReadCompleted += OnWebClientOpenReadCompleted;
    webClient.OpenReadAsync(new
    Uri("http://www.charlespetzold.com/Media/HelloWP7.jpg"));
    }
    void OnWebClientOpenReadCompleted(object sender, OpenReadCompletedEventArgs args)
    {
    if (!args.Cancelled && args.Error == null)
    {
    helloTexture = Texture2D.FromStream(this.GraphicsDevice, args.Result);
    }
    }

    Silverlight:

    protected override void OnManipulationStarted(ManipulationStartedEventArgs args)
    {
    WebClient webClient = new WebClient();
    webClient.OpenReadCompleted += OnWebClientOpenReadCompleted;
    webClient.OpenReadAsync(new
    Uri("http://www.charlespetzold.com/Media/HelloWP7.jpg"));
    args.Complete();
    args.Handled = true;
    base.OnManipulationStarted(args);
    }
    void OnWebClientOpenReadCompleted(object sender, OpenReadCompletedEventArgs args)
    {
    if (!args.Cancelled && args.Error == null)
    {
    BitmapImage bmp = new BitmapImage();
    bmp.SetSource(args.Result);
    img.Source = bmp;
    }
    }

    图片编译进入DLL字符串格式:

    "/SilverlightDemo;component/Images/HelloWorld.png"

  • 相关阅读:
    CF321B Solution
    CF722D Solution
    CF729E Solution
    CF1447E Solution
    CF962F Solution
    DropDownList绑定数据
    连接数据库
    jqm随记的东西
    正则表达式过滤超链接内容(.net)
    linq lambda操作list的例子
  • 原文地址:https://www.cnblogs.com/otomii/p/2029528.html
Copyright © 2011-2022 走看看