Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET convert image from PNG to jpg
    primarykey
    data
    text
    <p>I am having a problem with converting the image from PNG to JPG. From jpg to jpg is very good but from PNG to jpg is having a pixelated problem. I've already implemented the compression method into this code but it still couldn't produce a high quality image.</p> <p>Any ideas guys?</p> <pre><code>using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Drawing.Imaging; using System.Drawing; using System.IO; using System.Drawing.Drawing2D; public partial class _Default : System.Web.UI.Page { private ImageCodecInfo GetEncoder(ImageFormat format) { ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders(); foreach (ImageCodecInfo codec in codecs) { if (codec.FormatID == format.Guid) { return codec; } } return null; } protected void Page_Load(object sender, EventArgs e) { Response.ContentType = "image/JPEG";//convert toJPEG for web usage // Get a bitmap. Bitmap bmp1 = new Bitmap(@"E:\websites\LogoMaster\LogoID4.png"); ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg); // Create an Encoder object based on the GUID // for the Quality parameter category. System.Drawing.Imaging.Encoder myEncoder =System.Drawing.Imaging.Encoder.Quality; // Create an EncoderParameters object. // An EncoderParameters object has an array of EncoderParameter // objects. In this case, there is only one // EncoderParameter object in the array. EncoderParameters myEncoderParameters = new EncoderParameters(1); EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 100L);//SET to the highest quality myEncoderParameters.Param[0] = myEncoderParameter; // bmp1.Save(@"E:\websites\LogoMaster\TestPhotoQualityHundredp.jpg", jgpEncoder, myEncoderParameters); bmp1.Save(Response.OutputStream, jgpEncoder, myEncoderParameters); bmp1.Dispose(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload