我在Windows Phone 7中使用以下代码来保存具有特定大小的JPEG图像:
WriteableBitmap wBitmap = new WriteableBitmap(resizedImage);
MemoryStream m = new MemoryStream();
wBitmap.SaveJpeg(m, h, w, 0, 100);
我收到错误:
"WritableBitmap does contain a definition for SaveJpeg"
如何在带有C#的桌面Windows窗体应用程序上执行相同的操作?
答案 0 :(得分:3)
以下是你如何使用JpegBitmapEncoder
来做这件事(好吧,很滑稽,现在是srs)//Assuming resizedImage is a BitmapSource
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(resizedImage));
using(var stream = File.Open(theAristocratsFilename))
encoder.Save(stream);