Can't add System.Windows.Media.Imaging.JpegBitmapEncoder in WP

685 Views Asked by At

I'm trying to use the type JpegBitmapEncoderin 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?

1

There are 1 best solutions below

2
On

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();