Bmp to jpg/png in C#

前端 未结 7 1883
无人共我
无人共我 2020-11-29 01:41

Is there any way to convert a bmp image to jpg/png without losing the quality in C#? Using Image class we can convert bmp to jpg but the quality of output image is very poor

7条回答
  •  粉色の甜心
    2020-11-29 02:19

    I am working on an expense report app, and I am really pleased with the default quality settings for JPG (and PNG) when saving from a Bitmap object.

    https://msdn.microsoft.com/en-us/library/9t4syfhh%28v=vs.110%29.aspx

    Bitmap finalBitmap = ....; //from disk or whatever
    finalBitmap.Save(xpsFileName + ".final.jpg", ImageFormat.Jpeg);
    finalBitmap.Save(xpsFileName + ".final.png", ImageFormat.Png);
    

    I'm on .NET 4.6...perhaps the quality has improved in subsequent framework releases.

提交回复
热议问题