Пример #1
0
        static void Duplex(DuplexOptions opt)
        {
            DuplexBuilder duplexBuilder = new DuplexBuilder(
                new LoggerHelper("duplex"), TemplatesTools.getA4(150, !(opt.Landscape ?? true)), opt.Columns,
                padPercent: opt.Padding, spacePercent: opt.Spacing);

            Action <string> _file_job = new Action <string>((string input_file) =>
            {
                TryProcessFile("duplex-job-single", input_file, opt.OutputFolder, (file, output_file, log) =>
                {
                    duplexBuilder.saveCahpterFragmentsInto_PNG_LTR(
                        SplitFile(opt, input_file, file, output_file, log, duplexBuilder),
                        "",
                        opt.OutputFolder);
                });
            });


            List <PageFragmnet> dirFragments = new List <PageFragmnet>();
            Action <string, DirectoryInfo, string> _file_nested_job =
                new Action <string, DirectoryInfo, string>((string input_file, DirectoryInfo dir, string inputDir) =>
            {
                TryProcessFile("duplex-job-nested", input_file, opt.OutputFolder, (file, output_file, log) =>
                {
                    dirFragments.AddRange(
                        SplitFile(opt, input_file, file, output_file, log, duplexBuilder));
                });
            });

            Action <string, DirectoryInfo, bool> onDir = new Action <string, DirectoryInfo, bool>(
                (string inputFolder, DirectoryInfo currentInputDir, bool started) =>
            {
                if (!started)
                {
                    DirectoryInfo currentOutputDir = new DirectoryInfo(currentInputDir.FullName.Replace(inputFolder, opt.OutputFolder));
                    if (!currentOutputDir.Exists)
                    {
                        currentOutputDir.Create();
                    }
                    log.i("Saving fragments after folder to " + currentOutputDir.FullName);
                    duplexBuilder.saveCahpterFragmentsInto_PNG_LTR(dirFragments, "", currentOutputDir.FullName);
                }
                else
                {
                    dirFragments = new List <PageFragmnet>();
                }
            });

            ProcessAllFiles(opt, _file_job, nestedFileJob: _file_nested_job, onDirecotry: onDir, fileExt: "*.png");
        }
Пример #2
0
        private static List <PageFragmnet> SplitFile(
            DuplexOptions opt, string input_file, string file, string output_file, LoggerHelper log, DuplexBuilder d)
        {
            log.i(string.Format("Splitting strip: '" + file + "'"));
            var toon = new WebtoonPage()
            {
                filpath = input_file
            };

            using (MagickImage img = new MagickImage(file))
            {
                toon.height = img.Height;
                toon.width  = img.Width;
            }
            return(d.splitPageLandscape(toon));
        }