zoukankan      html  css  js  c++  java
  • WPF Image动态加载图片终极办法

    //Createsource BitmapImagemyBitmapImage= new BitmapImage(); 
    //BitmapImage.UriSourcemustbeinaBeginInit/EndInitblock 
    myBitmapImage.BeginInit(); myBitmapImage.UriSource= new 
    Uri(str,UriKind.Absolute); 
    //Tosavesignificantapplicationmemory,settheDecodePixelWid

    // Create source BitmapImage myBitmapImage = new BitmapImage(); // BitmapImage.UriSource must be in a BeginInit/EndInit block myBitmapImage.BeginInit(); myBitmapImage.UriSource = new Uri(str, UriKind.Absolute); // To save significant application memory, set the DecodePixelWidth or // DecodePixelHeight of the BitmapImage value of the image source to the desired // height or width of the rendered image. If you don't do this, the application will // cache the image as though it were rendered as its normal size rather then just // the size that is displayed. // Note: In order to preserve aspect ratio, set DecodePixelWidth // or DecodePixelHeight but not both. myBitmapImage.DecodePixelWidth = 2048; myBitmapImage.EndInit(); //set image source Image img = new Image(); img.Source = myBitmapImage;

    // Create source   
    BitmapImage myBitmapImage = new BitmapImage();   
       
       
    // BitmapImage.UriSource must be in a BeginInit/EndInit block   
    myBitmapImage.BeginInit();   
    myBitmapImage.UriSource = new Uri(str, UriKind.Absolute);   
       
       
    // To save significant application memory, set the DecodePixelWidth or     
    // DecodePixelHeight of the BitmapImage value of the image source to the desired    
    // height or width of the rendered image. If you don't do this, the application will    
    // cache the image as though it were rendered as its normal size rather then just    
    // the size that is displayed.   
    // Note: In order to preserve aspect ratio, set DecodePixelWidth   
    // or DecodePixelHeight but not both.   
    myBitmapImage.DecodePixelWidth = 2048;   
    myBitmapImage.EndInit();   
    //set image source   


    Image img = new Image(); 
    img.Source = myBitmapImage;

  • 相关阅读:
    2017-11-26 小组工作内容
    2017-11-25 小组工作内容
    2017-11-24 小组工作内容
    如何计算团队成员贡献分——1703班02组
    第一周小组博客作业——1703班02组
    2017-11-17实践作业记录
    第0次作业
    Unity3D 视频播放
    Unity3D 平滑转向
    Unity3D之Camera跟随鼠标移动,右键显示或隐藏鼠标
  • 原文地址:https://www.cnblogs.com/leelike/p/2420149.html
Copyright © 2011-2022 走看看