c# 图片等比缩略
2021-06-30 10:06
标签:map graph bic .com return 参数 图片 width pos public Bitmap getnew(Image bit, int TargetWidth, int TargetHeight)//beishu参数为放大的倍数。放大缩小都可以,0.8即为缩小至原来的0.8倍 c# 图片等比缩略 标签:map graph bic .com return 参数 图片 width pos 原文地址:https://www.cnblogs.com/LTEF/p/9981351.html
{
Bitmap destBitmap = new Bitmap(TargetWidth, TargetHeight);
Graphics g = Graphics.FromImage(destBitmap);
g.Clear(Color.Transparent);
//设置画布的描绘质量
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.DrawImage(bit, new Rectangle(0, 0, destBitmap.Width, destBitmap.Height), 0, 0, bit.Width, bit.Height, GraphicsUnit.Pixel);
g.Dispose();
return destBitmap;
}