c# – .NET FW BitmapImage类何时下载/缓存?
发布时间:2020-12-15 22:03:08 所属栏目:百科 来源:网络整理
导读:我对这堂课有点困惑,我希望有人可以解释一下. 我知道下载时取决于图像的 BitmapCreateOptions. 但是,当您创建绝对BitmapImage时,请说: var Image = new BitmapImage(new Uri("http://...",UriKind.Absolute)) 它不会马上下载,因为DelayCreation是默认的Bitm
我对这堂课有点困惑,我希望有人可以解释一下.
我知道下载时取决于图像的 BitmapCreateOptions. 但是,当您创建绝对BitmapImage时,请说: var Image = new BitmapImage(new Uri("http://...",UriKind.Absolute)) 它不会马上下载,因为DelayCreation是默认的BitmapCreateOptions,对吗? 如果你做了怎么办: var Image = new BitmapImage(new Uri("http://...",UriKind.Absolute)) Image.CreateOptions = BitmapCreateOptions.None; 设置BitmapCreateOptions后会立即开始下载图像吗? var Image = new BitmapImage(new Uri("http://...",UriKind.Absolute)) { CreateOptions = BitmapCreateOptions.None } 好的,现在,缓存如何为BitmapImage工作? > BitmapImage何时被“缓存”? 最后,ImageOpened和ImageFailed事件什么时候被提升? >只有在下载BitmapImage时它们才会被提升吗? 解决方法
我知道这已经晚了几个月,但是对于记录,下载是在调用EndInit时发生的,在此之后对属性的任何其他更改都将被丢弃.使用默认构造函数以外的构造函数将自动初始化图像.
换一种说法: var Image = new BitmapImage(new Uri("http://...",UriKind.Absolute)); // The image is now intialized and is downloading/downloaded Image.CreateOptions = BitmapCreateOptions.None; // nothing happens here 如果要设置属性,请手动初始化,如下所示: var Image = new BitmapImage(); Image.BeginInit(); Image.UriSource = new Uri("http://...",UriKind.Absolute) Image.CreateOptions = BitmapCreateOptions.None; // This is default anyway so it won't affect // ..Setting other properties... Image.EndInit(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- c# – SSH.NET – 找不到合适的认证方法
- ultraedit 正则 替换
- ios – 智能应用横幅可以启动从Xcode安装的应用吗?
- 开源监控解决方案:ICINGA(Nagios)监控Oracle Database
- ListView 使用自定义适配器,将自定义xml布局转换成view调整
- vb.net 类中属性中的事件 并向新加窗体中用代码添加控件
- c# – 何时适合使用CacheItemRemovedCallback?
- 在PostgreSQL上运行PL / R时,R可以处理比RAM更大的数据吗?
- ruby-on-rails – 无法在Cygwin上安装libv8 gem
- 【Python 第58课】 正则表达式(4)