コード例 #1
0
 public static int GetPageCount(string file)
 {
     using (var img = new FileSystemTiff(file))
     {
         return(img.Image.GetFrameCount(FrameDimension.Page));
     }
 }
コード例 #2
0
        public static List <InMemoryTiff> SplitFilesToMemory(List <string> filePaths)
        {
            Func <string, IEnumerable <InMemoryTiff> > splitToMemories = (filePath) =>
            {
                FileSystemTiff tiffFiles = new FileSystemTiff(filePath);
                return(tiffFiles.Split());
            };

            var resultDic = new Dictionary <int, List <InMemoryTiff> >();

            var fileTaskArray = new System.Threading.Tasks.Task[filePaths.Count];


            for (int i = 0; i < filePaths.Count; i++)
            {
                var filePath = filePaths[i];
                var index    = i;
                fileTaskArray[i] = System.Threading.Tasks.Task.Factory.StartNew(() =>
                {
                    resultDic.Add(index, splitToMemories(filePath).ToList());
                });
            }

            System.Threading.Tasks.Task.WaitAll(fileTaskArray);

            var result = new List <InMemoryTiff>();

            for (int i = 0; i < resultDic.Keys.Count; i++)
            {
                result.AddRange(resultDic[i]);
            }

            return(result);
        }