コード例 #1
0
        public static void SaveJPG(this Image img, Stream stream, int quality, bool fillBackground)
        {
            using (EncoderParameters encoderParameters = new EncoderParameters(1))
            {
                if (fillBackground)
                {
                    img = CaptureHelpers.FillImageBackground(img, Color.White);
                }

                encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, quality);
                img.Save(stream, ImageFormat.Jpeg.GetCodecInfo(), encoderParameters);
            }
        }