通常的图片的的格式有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);