Goal:
Save a picture from the harddrive into my WPF application. The picture should be available if copying the WPF application. The address to the picture located in the WPF application should be saved in the database.
目标:将harddrive中的图片保存到我的WPF应用程序中。如果复制WPF应用程序,则图片应该是可用的。位于WPF应用程序中的图片的地址应该保存在数据库中。
Problem:
How should I do it in a course of action?
问题:在行动过程中我应该怎么做?
private void btnBrowse_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.Filter = "jpg files (*.jpg)|*.jpg|gif files (*.gif)|*.gif|jpeg files (*.jpeg)|*.jpeg";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
// Open document
string filename = dlg.FileName;
txtPicture.Text = filename;
BitmapImage myBitmapImage = new BitmapImage(new Uri(dlg.FileName, UriKind.Absolute));
string sss = myBitmapImage.Format.ToString();
string asd = dlg.SafeFileName.ToString();
}
}
1 个解决方案
#1
0
There are several image encoders available. A simple example for PNG files can be found here, or a more complete sample here. The same concept applies for the other supported image file types.
有几个图像编码器可用。可以在这里找到PNG文件的简单示例,或者在这里找到更完整的示例。同样的概念也适用于其他支持的图像文件类型。
#1
0
There are several image encoders available. A simple example for PNG files can be found here, or a more complete sample here. The same concept applies for the other supported image file types.
有几个图像编码器可用。可以在这里找到PNG文件的简单示例,或者在这里找到更完整的示例。同样的概念也适用于其他支持的图像文件类型。