码迷,mamicode.com
首页 > Windows程序 > 详细

c# 图片等比缩略

时间:2018-11-19 11:18:34      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:map   graph   bic   .com   return   参数   图片   width   pos   

public Bitmap getnew(Image bit, int TargetWidth, int TargetHeight)//beishu参数为放大的倍数。放大缩小都可以,0.8即为缩小至原来的0.8倍
{
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;
}

c# 图片等比缩略

标签:map   graph   bic   .com   return   参数   图片   width   pos   

原文地址:https://www.cnblogs.com/LTEF/p/9981351.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!