I'm trying to use the type JpegBitmapEncoder
in the name space System.Windows.Media.Imaging
, but i can't seem to use it. The namespace itself is available and i can use it but for some reason the JpegBitmapEncoder is not there... How can i use it?
Asked
Active
Viewed 668 times
0

CodeMonkey
- 11,196
- 30
- 112
- 203
1 Answers
1
Perhaps you can use the extension methods on WritableBitmap to load and save a jpeg instead.
Extensions Methods - LoadJpeg, SaveJpeg
If you want to get a byte array from the image, use a MemoryStream
and its ToArray
to get the data.
MemoryStream stream = new MemoryStream();
image.SaveJpeg(stream, width, height, 0, 80);
stream.Position = 0;
byte[] buffer = stream.ToArray();

Patrick
- 17,669
- 6
- 70
- 85
-
also another question.. does it work on image of the type: System.Windows.Media.Imaging.BitmapImage ? – CodeMonkey Aug 22 '12 at 18:47
-
@YonatanNir: Yes, the WritableBitmap constructor takes a BitmapSource (which BitmapImage inherits from) so you simply write `new WritableBitmap(bitmapSource);` and then use the code above – Patrick Aug 22 '12 at 20:50