0

我正在尝试将 BitmapImage 保存在应用程序文件夹路径中。我正在使用以下代码

OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif";
var resultSaveDialog = fileDialog.ShowDialog();
if (fileDialog.FileName != "" && resultSaveDialog == System.Windows.Forms.DialogResult.OK)
{
    fileDialog.OpenFile();
    strPath = fileDialog.FileName;
    System.Windows.Media.Imaging.BitmapImage myBitmapImage = new System.Windows.Media.Imaging.BitmapImage();
    myBitmapImage.BeginInit();
    myBitmapImage.DecodePixelHeight = 20;
    myBitmapImage.DecodePixelWidth = 20;
    myBitmapImage.UriSource = new Uri(strPath, UriKind.Absolute);
    myBitmapImage.EndInit();                                      
    System.Windows.Media.ImageSource imgSource = myBitmapImage;     
 }           

我想将此保存myBitmapImage到应用程序文件夹 LA_Img。我该怎么做..我找不到任何方法..

4

1 回答 1

0

您可以使用BitmapEncoder。请参阅System.Windows.Media.Imaging-Namespace了解派生类,如JpegBitmapEncoderPngBitmapEncoder

于 2013-06-05T09:31:22.053 回答