您的位置:首页 > 编程语言 > C#

C# 图片编辑和多种格式间转换

2017-01-13 22:58 148 查看
通常的图片的的格式有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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息