congqiandehoulai
    var img = System.Drawing.Image.FromStream(ms);

                            int width = img.Width;
                            int height = img.Height;
                            var x = img.HorizontalResolution;
                            var y = img.VerticalResolution;
                            var tempHeight = height * 300 / y;
                            var tempWidth = width * 300 / y;
                            Bitmap bmpTemp = new Bitmap((int)tempWidth, (int)tempHeight);
                            Graphics g = Graphics.FromImage(bmpTemp);
                            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                            g.Clear(System.Drawing.Color.White);
                            g.DrawImage(img, new RectangleF(0, 0, tempWidth, tempHeight), new RectangleF(0, 0, width, height), GraphicsUnit.Pixel);
                            g.Save();

                            bmpTemp.Save(target, ImageFormat.Png);
                            g.Dispose();
                            img.Dispose();
                            bmpTemp.Dispose();

 

感谢每一位阅读此篇文章的人,希望可以帮到你。

分类:

技术点:

相关文章:

  • 2021-07-30
  • 2021-12-23
  • 2021-12-08
  • 2022-12-23
  • 2021-09-07
  • 2021-11-30
  • 2022-01-15
  • 2021-12-26
猜你喜欢
  • 2021-12-13
  • 2021-12-13
  • 2021-12-13
  • 2021-12-13
  • 2021-12-13
  • 2021-12-29
  • 2021-11-01
相关资源
相似解决方案