使用dailogbox加载图像 [英] loading image using dailogbox
本文介绍了使用dailogbox加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用打开文件对话框将位图图像加载到墨水画布中,而不是通过确定 this code之类的路径来做到这一点? pre lang ="c#"> ImageBrush ib = 新 ImageBrush(); ib.ImageSource = 新 BitmapImage(新 Uri( @" E:\ ss.jpg",UriKind.Relative)); myInkCanvas.Background = ib;
解决方案
好吧,它始终在 ^ ].您没有在MSDN上找到问题的答案吗?
查看文档,并检查如何使用OpenFileDialog使用户能够从文件系统中选择文件.
下面的示例代码如下,
// 创建实例 OpenFileDialog fileOpener = 新 OpenFileDialog(); // 设置属性.. // 仅选择一个文件 fileOpener.MultiSelect = false ; // 显示对话框,返回可为空的布尔值 布尔?结果= openFileDialog1.ShowDialog(); 如果(结果== 真){ 选中// 文件,检查并使用该文件 // 在您的应用程序中. }
Hi,I''m trying to loade a bitmap image into inkcanvas using open file dialog , not by determine the path like this code how can do this ?
ImageBrush ib = new ImageBrush();
ib.ImageSource = new BitmapImage(new Uri(@"E:\ss.jpg", UriKind.Relative));
myInkCanvas.Background = ib;
解决方案
Well it was always available on MSDN[^]. Didn''t you look on MSDN to find an answer to the problem?
Look into the documentation and check how can you get the user to be able to get a file selected from the File System using the OpenFileDialog.
Example code for this would like as below,
// create instance OpenFileDialog fileOpener = new OpenFileDialog(); // set properties.. // select only one file fileOpener.MultiSelect = false; // show the dialog, returns nullable bool value bool? result = openFileDialog1.ShowDialog(); if(result == true) { // file selected, check for the file and use it // in your application. }
这篇关于使用dailogbox加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文