Example #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");
        }
Example #2
0
        public void CombiningTwoSplittedStripsTogether2()
        {
            Size          A4            = Bindings.TemplatesTools.getA4(96, false);
            DuplexBuilder duplexBuilder = new DuplexBuilder(
                new Tools.LoggerHelper("test"),
                A4,
                3,
                padPercent: 0f
                );

            WebtoonPage page = new WebtoonPage()
            {
                filpath = "p1.png",
                width   = 690,
                height  = 212,
            };
            WebtoonPage page2 = new WebtoonPage()
            {
                filpath = "p2.png",
                width   = 690,
                height  = 1885,
            };

            DrawMock mock = new DrawMock();


            List <PageFragmnet> fragmantsToRead = new List <PageFragmnet>();

            fragmantsToRead.AddRange(duplexBuilder.splitPageLandscape(page));
            fragmantsToRead.AddRange(duplexBuilder.splitPageLandscape(page2));

            printFrags(fragmantsToRead);

            var outputPages = duplexBuilder.saveCahpterFragmentsInto_PNG_LTR(
                fragmantsToRead,
                "",
                "",
                mock: mock
                );

            var usedColumns     = outputPages.Sum((p) => p.ColCount());
            var usedPrintOrders = outputPages.Sum((p) => (p.GetCols.Sum((c) => c.getPrintSources.Count)));

            Assert.AreEqual(4, usedPrintOrders);

            CheckDrawInsideBounds(mock, usedColumns, 2);
        }
Example #3
0
        public void CombiningTwoSplittedStripsTogether()
        {
            Size          A4            = Bindings.TemplatesTools.getA4(96, false);
            DuplexBuilder duplexBuilder = new DuplexBuilder(
                new Tools.LoggerHelper("test"),
                A4,
                3,
                padPercent: 0f
                );

            int colW = A4.Width / 3;
            int colH = A4.Height;

            WebtoonPage page = new WebtoonPage()
            {
                filpath = "p1.png",
                width   = colW,
                height  = (int)(colH * 1.2f),
            };
            WebtoonPage page2 = new WebtoonPage()
            {
                filpath = "p2.png",
                width   = colW,
                height  = (int)(colH * 1.2f),
            };

            DrawMock            mock            = new DrawMock();
            List <PageFragmnet> fragmantsToRead = new List <PageFragmnet>();

            fragmantsToRead.AddRange(duplexBuilder.splitPageLandscape(page));
            fragmantsToRead.AddRange(duplexBuilder.splitPageLandscape(page2));

            printFrags(fragmantsToRead);

            var outputPages = duplexBuilder.saveCahpterFragmentsInto_PNG_LTR(
                fragmantsToRead,
                "",
                "",
                mock: mock
                );

            var usedColumns = outputPages.Sum((p) => p.ColCount());

            CheckDrawInsideBounds(mock, usedColumns, 3);
        }