为什么我不能在以下代码中创建CroppedBitmap?我有一个例外:
调用线程无法访问此对象,因为另一个线程拥有它.
如果我将代码更改为
CroppedBitmap cb = new CroppedBitmap(new WriteableBitmap(bf), new Int32Rect(1, 1, 5, 5));
Run Code Online (Sandbox Code Playgroud)
异常消失了吗?为什么?
代码1,例外情况cb.Freeze():
public MainWindow()
{
InitializeComponent();
ThreadPool.QueueUserWorkItem((o) =>
{
//load a large image file
var bf = BitmapFrame.Create(
new Uri("D:\\1172735642.jpg"),
BitmapCreateOptions.None,
BitmapCacheOption.None);
bf.Freeze();
Dispatcher.BeginInvoke(
new Action(() =>
{
CroppedBitmap cb = new CroppedBitmap(bf, new Int32Rect(1,1,5,5));
cb.Freeze();
//set Image's source to cb....
}),
DispatcherPriority.ApplicationIdle);
}
);
}
Run Code Online (Sandbox Code Playgroud)
代码2,有效:
ThreadPool.QueueUserWorkItem((o) =>
{
var bf = BitmapFrame.Create(
new Uri("D:\\1172740755.jpg"),
BitmapCreateOptions.None,
//BitmapCreateOptions.DelayCreation,
BitmapCacheOption.None);
bf.Freeze();
var wb = new …Run Code Online (Sandbox Code Playgroud) 我想访问网络共享文件.如何显示系统验证对话框,以便用户可以输入用户名和密码?
ps:通过UNC,在WinForm中.
我正在编写一个探索控件,我想在用户双击网络共享文件夹后显示该对话框.
如何从使用C#的Apple iPhone拍摄的图像中读取EXIF数据?
我需要GPS相关数据.
PS:除了使用Apple iPhone拍摄的图像外,我知道如何阅读EXIF