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;

  • 相关阅读:
    欧拉函数、欧拉定理、费马小定理、拓展欧拉定理
    $CF 635 (Div 2)$
    $CF 634 (Div 3)$
    $CF 633 (Div 2)$
    $ACM$ 课第三次作业-搜索
    《信息安全数学基础一》第一章笔记
    接口测试工具与接口测试框架
    【python】基础知识小结
    【mongo】多个字段进行分组查询
    【mongo】去重操作
  • 原文地址:https://www.cnblogs.com/leelike/p/2420149.html
Copyright © 2011-2022 走看看