图片合成

作者:追风剑情 发布于:2022-1-28 11:05 分类:C#

/// <summary>
/// 图片合成辅助类
/// </summary>
public sealed class CombinImageHelper
{
	//合成多张图片
	public static Image CombinImage(params string[] filePathArr)
	{
		Image img0 = Image.FromFile(filePathArr[0]);
		Graphics g = Graphics.FromImage(img0);
		for (int i = 1; i < filePathArr.Length; i++)
		{
			Image img = Image.FromFile(filePathArr[i]);
			g.DrawImage(img, 0, 0, img.Width, img.Height);
		}
		GC.Collect();
		return img0;
	}

	//合成多张图片
	public static Image CombinImages(string[] filePathArr)
	{
		Image img0 = Image.FromFile(filePathArr[0]);
		Graphics g = Graphics.FromImage(img0);
		for (int i = 1; i < filePathArr.Length; i++)
		{
			Image img = Image.FromFile(filePathArr[i]);
			g.DrawImage(img, 0, 0, img.Width, img.Height);
		}
		GC.Collect();
		return img0;
	}
}

标签: C#

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号