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;

  • 相关阅读:
    Codeforces Round #131 (Div. 2) E. Relay Race dp
    Codeforces Round #130 (Div. 2) C
    Codeforces Round #130 (Div. 2) A. Dubstep
    UVA 11858 Frosh Week 逆序对统计
    UVA 11149 Power of Matrix 快速幂
    UVA 12382 Grid of Lamps 贪心
    POJ 3614 Sunscreen 贪心
    Codeforces Round #238 (Div. 2) D. Toy Sum 暴搜
    Codeforces Round #227 (Div. 2) E. George and Cards 线段树+set
    Codeforces Round #327 (Div. 2) E. Three States
  • 原文地址:https://www.cnblogs.com/leelike/p/2420149.html
Copyright © 2011-2022 走看看