泰安企业网站建设,网业无法打开怎么办,WordPress博客首页如何静态,wordpress 主题右边栏本次程序编写主要为了将pdf word等文档转换为图片后设置不同的打印排版 前提 目标文件夹中的图片高宽都是一致的 /// summary/// 合并图片/// /summary/// param namesavedictory文件保存目录/param/// param namesingl…本次程序编写主要为了将pdf word等文档转换为图片后设置不同的打印排版 前提 目标文件夹中的图片高宽都是一致的 /// summary/// 合并图片/// /summary/// param namesavedictory文件保存目录/param/// param namesinglePageNumber单页排版/param/// param namepath文件列表/param/// public static void MergedImage(string[] path, SinglePageNumber singlePageNumber,string savedictory){//获取目录路径列表var i path.Length % (int)singlePageNumber 0 ? (path.Length / (int)singlePageNumber 1) : path.Length / (int)singlePageNumber;for (int s 0; s i; s){ListBitmap bitmapList new ListBitmap();Liststring imgPathTake path.Skip((s - 1) * (int)singlePageNumber).Take((int)singlePageNumber).ToList();foreach (var pathItem in imgPathTake)bitmapList.Add(new Bitmap(pathItem));//21x2 42x2 62x3 93x3 164x4Bitmap map null;switch (singlePageNumber){case SinglePageNumber.two:map mergeImage(2, 1, bitmapList);break;case SinglePageNumber.four:map mergeImage(2, 2, bitmapList);break;case SinglePageNumber.six:map mergeImage(3, 2, bitmapList);break;case SinglePageNumber.nine:map mergeImage(3, 3, bitmapList);break;case SinglePageNumber.Sixteen:map mergeImage(4, 4, bitmapList);break;default:break;}map.Save(savedictory \\ s.png);}}/// summary/// 合并图片文件 传入的图片宽高要一致/// /summary/// param namewi一排有几张/param/// param namehi一列有几张/param/// param namemapList/parampublic static Bitmap mergeImage(int wi, int hi, ListBitmap mapList){int width mapList.First().Width;int height mapList.First().Height;Bitmap bitmap new Bitmap(width * wi, height * hi);//x表示图片在第几行y表示图片在第几列 int mapIndex 0;for (int y 1; y hi; y){for (int x 1; x wi; x){if (mapIndex mapList.Count ){foreach (var item in mapList)item.Dispose();return bitmap;}var map mapList[mapIndex];mapIndex;for (int w 1; w width; w)for (int h 1; h height; h){var color map.GetPixel(w - 1, h - 1);bitmap.SetPixel(((x-1)*width)w - 1, ((y - 1) * height) h - 1, color);}}}foreach (var item in mapList)item.Dispose();return bitmap;}/// summary/// 每版打印几页 单页的不用处理/// /summarypublic enum SinglePageNumber{two 2,four 4,six 6,nine 9,Sixteen 16,}设置图片排版为2*3的效果 string dictory D:\test\testpdf2convert\;string[] path System.IO.Directory.GetFiles(dictory);ImagePrintHp.MergedImage(path, SinglePageNumber.six, dictory);效果 2*2效果 转载于:https://www.cnblogs.com/ProDoctor/p/7691575.html