通常的图片的的格式有jpg 、png、jpeg、bmp等等,有时候需要对图片进行压缩,格式之间的转换。
C# 中通过GDI+ 位图
Bitmap srcImage=new Bitmap(path);//原始图片
//新建位图
Bitmap newbit=new Bitmap(w,h);//w 为长度,h为宽度
//GDI+ 绘图图面
Graphics g=Graphics.FromImage(newbit);
// 插值算法的质量
g.InterpolationMode = InterpolationMode.Default;
g.DrawImage(srcImage, new System.Drawing.Rectangle(0, 0, w, h), new System.Drawing.Rectangle(0, 0, srcImage.Width, srcImage.Height), System.Drawing.GraphicsUnit.Pixel);
newbit.save(newpath);
本文介绍如何使用C#中的GDI+进行图片压缩及格式转换,包括创建位图、设置绘图质量等关键步骤。
599

被折叠的 条评论
为什么被折叠?



