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"

  • 相关阅读:
    [BZOJ1584][Usaco2009 Mar]Cleaning Up 打扫卫生
    CSS浮动
    Django by example -----1总结
    C#函数重载
    linux目录的特点
    Linux调优
    linux
    对齐方式
    19-10-25-G-悲伤
    19-10-24-H
  • 原文地址:https://www.cnblogs.com/otomii/p/2029528.html
Copyright © 2011-2022 走看看