Пример #1
0
        /// <summary>
        /// Saves the indicated Page Image List as a fax tiff at the outputFilePath location using the quality option specified with AutoPageSize
        /// </summary>
        /// <param name="pages">The Images to save.</param>
        /// <param name="quality">Tiff Normal or Fine</param>
        /// <param name="paperSize">Letter, Legal or Auto</param>
        /// <param name="outputFilePath">Fully qualified file name and path.</param>
        /// <returns></returns>
        public static ImageOperationResult SaveAsFaxTiff(List <PageImage> pages, string outputFilePath, FaxQuality quality = FaxQuality.Normal, PaperSize paperSize = PaperSize.Auto)
        {
            ImageOperationResult ret = new ImageOperationResult();

            ret = ImageUtility.InternalSaveAsFaxTiff(pages, quality, paperSize, outputFilePath);

            return(ret);
        }
Пример #2
0
        /// <summary>
        /// Saves the indicated Page Image List as a fax tiff at the outputFilePath location using the quality option specified with AutoPageSize
        /// </summary>
        /// <param name="pages">The Images to save.</param>
        /// <param name="quality">Tiff Normal or Fine</param>
        /// <param name="paperSize">Letter, Legal or Auto</param>
        /// <param name="outputFilePath">Fully qualified file name and path.</param>
        /// <returns></returns>
        internal static ImageOperationResult InternalSaveAsFaxTiff(List <PageImage> pages, FaxQuality quality, PaperSize paperSize, string outputFilePath)
        {
            ImageOperationResult result = new ImageOperationResult();

            List <PageImage> newPages = ImageConverter.ConvertToFaxablePageImageList(pages, quality, paperSize, result);

            ImageUtility.SavePagesAsFaxTiffFile(newPages, outputFilePath);

            result.Pages = newPages.Count;

            ImageUtility.Dispose(newPages);

            return(result);
        }
Пример #3
0
        public static ImageOperationResult VerifyAllTiffFilesAndWriteFaxTiff(List <PageImage> pages, string outputFilePath, PaperSize paperSize, FaxQuality faxQuality)
        {
            ImageOperationResult ret = new ImageOperationResult();

            List <PageImage> newpages = ImageConverter.CreateFaxTiff(pages, paperSize, faxQuality, ret);

            ImageUtility.Dispose(pages);

            ImageUtility.SavePagesAsFaxTiffFile(newpages, outputFilePath);

            ret.Pages = newpages.Count;

            ImageUtility.Dispose(newpages);

            return(ret);
        }
Пример #4
0
        public static ImageOperationResult CropAndVerifyAllTiffFilesAndWriteFaxTiff(List <string> inputFilePaths, string outputFilePath)
        {
            ImageOperationResult ret = new ImageOperationResult();

            List <PageImage> pages = ImageUtility.LoadImage(inputFilePaths.ToArray(), false);

            var newPages = ImageConverter.CreateCroppedPageImageList(pages);

            ImageUtility.Dispose(pages);

            ImageUtility.SavePagesAsFaxTiffFile(newPages, outputFilePath);

            ret.Pages = newPages.Count;

            ImageUtility.Dispose(newPages);

            return(ret);
        }
Пример #5
0
        private static PageImage CreateFaxTiffFastTrack(PageImage page, PaperSize paperSize, FaxQuality faxQuality, ImageOperationResult result)
        {
            PageInfo  inf     = null;
            PageImage ret     = new PageImage();
            Bitmap    src     = null;
            Bitmap    destroy = null;

            src = BitmapHelper.CreateCopy1BppIndexed(page._sourceBmp);
            inf = new PageInfo(src);

            //If the size is not right copy to other size (padding or reducing)
            if (inf.GetStandardPaperSize != paperSize)
            {
                if (inf.GetStandardPaperSize == PaperSize.Legal && paperSize == PaperSize.Letter)
                {
                    destroy = src;
                    src     = BitmapHelper.CreateCopyFaxGeometry(src, faxQuality, paperSize, ImageUtility.InterpolationMode);
                    if (destroy != null)
                    {
                        destroy.Dispose(); destroy = null;
                    }
                    inf = new PageInfo(src);
                }
                if (inf.GetStandardPaperSize == PaperSize.Letter && paperSize == PaperSize.Legal)
                {
                    destroy = src;
                    src     = BitmapHelper.CreateCopyFaxGeometryPadding(src, faxQuality, paperSize);
                    if (destroy != null)
                    {
                        destroy.Dispose(); destroy = null;
                    }
                    inf = new PageInfo(src);
                }
            }

            //Make sure its 1bpp
            if (inf.PixelFormat != PixelFormat.Format1bppIndexed)
            {
                destroy = src;
                src     = BitmapHelper.CreateCopy1BppIndexed(src);
                if (destroy != null)
                {
                    destroy.Dispose(); destroy = null;
                }
                inf = new PageInfo(src);
            }

            //Reduce or increase quality as needed
            if (inf.GetStandardFaxQuality != faxQuality)
            {
                if (inf.GetStandardFaxQuality == FaxQuality.Fine && faxQuality == FaxQuality.Normal)
                {
                    destroy = src;
                    src     = BitmapHelper.ConvertTiffHiToTiffLow(src, ImageUtility.HighToLowScaleMethod);
                    if (destroy != null)
                    {
                        destroy.Dispose(); destroy = null;
                    }
                    inf = new PageInfo(src);
                }
                if (inf.GetStandardFaxQuality == FaxQuality.Normal && faxQuality == FaxQuality.Fine)
                {
                    destroy = src;
                    src     = BitmapHelper.ConvertTiffLowToTiffHi(src);
                    if (destroy != null)
                    {
                        destroy.Dispose(); destroy = null;
                    }
                    inf = new PageInfo(src);
                }
            }

            ret._pageInfo  = null;
            ret._sourceBmp = src;

            return(ret);
        }
Пример #6
0
        private static PageImage CreateFaxTiff(PageImage page, PaperSize paperSize, FaxQuality faxQuality, ImageOperationResult result, bool fastTrack)
        {
            PageImage ret = new PageImage();

            //FastTrack
            //if(page.PageInfo.IsStandardFaxTiff)
            if (fastTrack)
            {
                Trace.WriteLine("FastTracking tiff creation", MODNAME);
                return(CreateFaxTiffFastTrack(page, paperSize, faxQuality, result));
            }
            else
            {
                Trace.WriteLine("SlowTracking tiff creation", MODNAME);
                return(CreateFaxTiffSlowTrack(page, paperSize, faxQuality, result));
            }
        }
Пример #7
0
        /// <summary>
        /// Receives a page image list and returns a faxable page image list.
        /// </summary>
        /// <param name="pages"></param>
        /// <param name="paperSize"></param>
        /// <param name="faxQuality"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        internal static List <PageImage> CreateFaxTiff(List <PageImage> pages, PaperSize paperSize, FaxQuality faxQuality, ImageOperationResult result)
        {
            paperSize = ImageConverter.GetBestFitPaperSizeForList(pages, paperSize);
            if (faxQuality == FaxQuality.Default)
            {
                faxQuality = FaxQuality.Normal;
            }
            if (faxQuality == FaxQuality.Undefined)
            {
                faxQuality = FaxQuality.Normal;
            }

            bool fastTrack = CanFastTrackPageImageList(pages, paperSize);

            List <PageImage> ret = new List <PageImage>();

            for (int i = 0; i < pages.Count; i++)
            {
                ret.Add(CreateFaxTiff(pages[i], paperSize, faxQuality, result, fastTrack));
            }
            return(ret);
        }
Пример #8
0
        internal static List <PageImage> ConvertToFaxablePageImageList(List <PageImage> pages, FaxQuality quality, PaperSize paperSize, ImageOperationResult result)
        {
            if (pages.Count == 0)
            {
                return(new List <PageImage>());
            }

            FaxQuality targetquality = quality;
            PaperSize  targetsize    = ImageConverter.GetBestFitPaperSizeForList(pages, PaperSize.Auto);

            List <PageImage> ret = new List <PageImage>();

            for (int i = 0; i < pages.Count; i++)
            {
                ret.Add(new PageImage());
            }

            for (int i = 0; i < ret.Count; i++)
            {
                ret[i] = CreateFaxTiffSlowTrack(pages[i], targetsize, targetquality, result);
            }

            return(ret);
        }
Пример #9
0
        private static PageImage CreateFaxTiffSlowTrack(PageImage page, PaperSize paperSize, FaxQuality faxQuality, ImageOperationResult result)
        {
            PageInfo  inf     = null;
            PageImage ret     = new PageImage();
            Bitmap    src     = null;
            Bitmap    destroy = null;

            Trace.WriteLine("SlowTrack: CreateCopyExact...", MODNAME);
            src = BitmapHelper.CreateCopyExact(page._sourceBmp);
            Trace.WriteLine("SlowTrack: CreateCopyExact done.", MODNAME);
            inf = new PageInfo(src);

            if (inf.GetBestFitRotation != 0)
            {
                Trace.WriteLine("SlowTrack: Rotating...", MODNAME);
                destroy = src;
                src     = BitmapHelper.CreateCopyRotate(src, 90);
                if (destroy != null)
                {
                    destroy.Dispose(); destroy = null;
                }
                inf = new PageInfo(src);
                Trace.WriteLine("SlowTrack: Rotating done.", MODNAME);
            }

            destroy = src;
            Trace.WriteLine("SlowTrack: CreateCopyFaxGeometry...", MODNAME);
            src = BitmapHelper.CreateCopyFaxGeometry(src, faxQuality, paperSize, ImageUtility.InterpolationMode);
            Trace.WriteLine("SlowTrack: CreateCopyFaxGeometry done.", MODNAME);
            if (destroy != null)
            {
                destroy.Dispose(); destroy = null;
            }
            inf = new PageInfo(src);

            destroy = src;
            Trace.WriteLine("SlowTrack: CreateCopy1BppIndexed: " + ImageUtility.ConvertTo1BppMethod.ToString() + "...", MODNAME);
            src = BitmapHelper.CreateCopy1BppIndexed(src);
            Trace.WriteLine("SlowTrack: CreateCopy1BppIndexed done.", MODNAME);
            if (destroy != null)
            {
                destroy.Dispose(); destroy = null;
            }
            inf = new PageInfo(src);

            ret._pageInfo  = null;
            ret._sourceBmp = src;
            return(ret);
        }
Пример #10
0
        public static List <PageImage> ConvertToFaxPageImageList(List <PageImage> pages, FaxQuality quality, PaperSize paperSize)
        {
            ImageOperationResult result = new ImageOperationResult();

            return(ImageConverter.ConvertToFaxablePageImageList(pages, quality, paperSize, result));
        }