WPF 圖片格式轉換
//FileStream imageStreamSource = File.OpenRead(srcPath);
FileStream imageStreamSource = new FileStream(srcPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
BitmapDecoder decoder = BitmapDecoder.Create(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapFrame bitmapFrame = decoder.Frames[0];
//在介面上顯示圖片
//image1.Source = bitmapFrame;
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(bitmapFrame);
FileStream fstream = new FileStream(dstPath, FileMode.Create, FileAccess.ReadWrite);
encoder.Save(fstream);
fstream.Close();
fstream.Dispose();
imageStreamSource.Close();
imageStreamSource.Dispose();