Search code examples
c#windows-phone-7xna-4.0

How do you set the quality for RenderTarget2D.SaveAsJpeg()?


public void SaveAsJpeg(Stream stream, int width, int height)

RenderTarget2D.SaveAsJpeg() is missing a parameter to set the Jpeg quality and the output has lots of artifacts. (increasing the size of the image does help a bit but it still looks bad)

Is that parameter hidden somewhere in XNA? How can I improve the quality of the jpeg?


Solution

  • There is no quality parameter in the XNA 4.0 API for encoding JPEG images.

    As a very round-about way of doing things, you may be able to create a Silverlight WriteableBitmap, copy the data out of your render target and into that, and then use Extensions.SaveJpeg to save it with a custom quality level.

    A better alternative might be to simply save a PNG image.