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;
}