WPF Image动态加载图片终极办法
2012-03-27 20:58
363 查看
//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;
相关文章推荐
- wpf Image动态加载图片终极解决办法
- wpf Image动态加载图片终极解决办法 .
- vue 动态加载图片src的解决办法
- 在Flash的AS2中加载外部文件(图片/SWF/文本)的办法
- 动态加载图片
- 关于Unity3D中Resources动态加载NGUI图片的方法
- jQuery页面滚动图片等元素动态加载实现
- Flex动态加载svg图片
- 实现动态加载的图片页面中纵向居中显示
- iPhone table 实现动态加载图片的教程
- Android ListView,GridView,RecyclerView图片加载错位闪动问题解决办法
- NGUI---动态加载uiatlas和图片
- Android使用WebView加载本地图片终极大杀招
- jQuery在页面加载时动态修改图片尺寸的方法
- 关于Android加载图片OOM之Fresco解决办法
- ListView动态加载网络数据的解决办法
- EasyUI的treegrid组件动态加载数据问题的解决办法
- Resources动态加载NGUI图片的方法
- 网页动态加载图片 通过JS和jquery实现。
- iphone table 实现动态加载图片