save - c#: reduced image quality when saving JPEG at 100% quality -
i'm loading jpeg image , saving without manipulation it. image quality noticeably reducing.
here code:
bitmap imgoutput = new bitmap(@"d:\image.jpg"); graphics outputgraphics = graphics.fromimage(imgoutput); encoderparameters myencoderparameters = new encoderparameters(3); myencoderparameters.param[0] = new encoderparameter(system.drawing.imaging.encoder.quality, 100l); myencoderparameters.param[1] = new encoderparameter(system.drawing.imaging.encoder.scanmethod, (int)encodervalue.scanmethodinterlaced); myencoderparameters.param[2] = new encoderparameter(system.drawing.imaging.encoder.rendermethod, (int)encodervalue.renderprogressive); imagecodecinfo[] codecs = imagecodecinfo.getimageencoders(); imagecodecinfo ici = null; foreach (imagecodecinfo codec in codecs) { if (codec.mimetype == "image/jpeg") ici = codec; } imgoutput.save(@"d:\result.jpg", ici, myencoderparameters);
and get: http://i.imgur.com/5bg1tpm.jpg zoom: http://i.imgur.com/vdx8sl5.jpg
is there image quality settings?
jpeg, being lossy format introduces loss on every save. particularly bad @ compressing sharp edges. according this msdn article, you're setting image quality correctly. can play other settings if want try , optimize image quality, don't know how came scanmethod , rendermethod. however, best way in opinion use lossless format (png, tiff, etc).
update
it appears due bad gdi+ jpeg encoder. more on on the msdn forums. conclusion - use third party imaging library, there plenty free ones out there.
Comments
Post a Comment