Reputation: 14835
I am using the following code in Windows Phone 7 to save a JPEG image with a specific size:
WriteableBitmap wBitmap = new WriteableBitmap(resizedImage);
MemoryStream m = new MemoryStream();
wBitmap.SaveJpeg(m, h, w, 0, 100);
I am getting the error:
"WritableBitmap does contain a definition for SaveJpeg"
How do I do the same thing on a desktop Windows Forms app with C#?
Upvotes: 2
Views: 1295
Reputation:
Here's how you would do this (okay, was facetious, now am srs) using the JpegBitmapEncoder
//Assuming resizedImage is a BitmapSource
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(resizedImage));
using(var stream = File.Open(theAristocratsFilename))
encoder.Save(stream);
Upvotes: 4