C# 图片合成(复制即可)

System.Drawing.dll

不想说什么,直接用就好了

立即下载

引用System.Drawing.dll

		static private void CombinImage()
		{
			const string folder = @"F:\测试图片";
			Image img1 = Image.FromFile(Path.Combine(folder, "测试1.tif"));
			Bitmap map1 = new Bitmap(img1);
			Image img2 = Image.FromFile(Path.Combine(folder, "测试2.tif"));
			Bitmap map2 = new Bitmap(img2);
			Image img3 = Image.FromFile(Path.Combine(folder, "测试3.tif"));
			Bitmap map3 = new Bitmap(img3);
			var width = Math.Max(img1.Width, img2.Width);
			var height = img1.Height + img2.Height + 10;
			// 初始化画布(最终的拼图画布)并设置宽高
			Bitmap bitMap = new Bitmap(width, height);
			// 初始化画板
			Graphics g1 = Graphics.FromImage(bitMap);
			// 将画布涂为白色(底部颜色可自行设置)
			g1.FillRectangle(Brushes.White, new Rectangle(0, 0, width, height));
			//在x=0,y=0处画上图一
			g1.DrawImage(map1, 0, 0, img1.Width, img1.Height);
			//在x=0,y在图一往下10像素处画上图二
			g1.DrawImage(map2, 0, img1.Height + 10, img2.Width, img2.Height);
			g1.DrawImage(map3, 0, img1.Height + 10, img3.Width, img3.Height);
			map1.Dispose();
			map2.Dispose();
			map3.Dispose();
			Image img = bitMap;
			//保存
			img.Save(Path.Combine(folder, "new测试1.tif"));
			img.Dispose();
		}
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客
应支付0元
点击重新获取
扫码支付

支付成功即可阅读