• 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;

  • 相关阅读:
    Learning Rhino 1
    Learning Rhino 2
    JavaScript tips and tricks 5
    Observer pattern in JavaScript
    敏捷开发的原则
    什么是CLS?
    整理一些小东西,留个备份
    一个调查结果(在下一个版本的VS/C#中你想要什么?)
    如何知道一个类都实现了哪些接口和从那个类继承
    敏捷软件开发主要包括哪些方法
  • 原文地址:https://www.cnblogs.com/leelike/p/2420149.html
Copyright © 2020-2023  润新知