Ejemplo n.º 1
0
        public static Image ConvertTo32BitBitmap(List <PageImage> pageImageList)
        {
            string newfile = Path.GetTempFileName();

            ImageUtility.SaveAs32BitTiff(pageImageList, newfile);
            ImageUtility.Dispose(pageImageList);
            Image ret = Image.FromFile(newfile);

            return(ret);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Saves the indicated Image object as a fax tiff at the outputFilePath location using the quality option specified with AutoPageSize
        /// </summary>
        /// <param name="img">The Image object 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(Image img, string outputFilePath, FaxQuality quality = FaxQuality.Normal, PaperSize paperSize = PaperSize.Auto)
        {
            ImageOperationResult ret = new ImageOperationResult();

            List <PageImage> pages = ImageUtility.LoadImage(img);

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

            ImageUtility.Dispose(pages);

            return(ret);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a new PageImageList containing pages with only two colors (Black and White).
        /// The returned pixel format will be the same as the source pixel format.
        /// The given page image list is not altered.
        /// </summary>
        /// <param name="pages">The PageImageList to alter.</param>
        /// <param name="threshold">The threshold to use for converting to bitonal. Default is 500.</param>
        /// <returns>The new PageImageList.</returns>
        private static List <PageImage> ApplyMonochromeFilter(List <PageImage> pages, int threshold = 500)
        {
            //Get out if source is empty
            if (pages.Count == 0)
            {
                return(new List <PageImage>());
            }

            List <PageImage> ret = ImageConverter.CreateEmptyPageImageList(pages, PixelFormat.Format32bppArgb);

            List <PageImage> source = null;

            //If the pages are consistent 32 bit then continue
            bool consistentPixelFormat = ImageConverter.IsListPixelFormatConsistent(pages);

            if (consistentPixelFormat && pages[0].PageInfo.PixelFormat == PixelFormat.Format32bppArgb)
            {
                source = pages;
                for (int i = 0; i < source.Count; i++)
                {
                    ImageConverter.ApplyMonochromeFilter(source[i], ret[i], threshold);
                }
            }
            else
            {
                source = ImageConverter.CreateEmptyPageImageList(pages, PixelFormat.Format32bppArgb);
                for (int i = 0; i < pages.Count; i++)
                {
                    ImageConverter.DrawSourcePageToDestination(pages[i], source[i], ImageUtility.InterpolationMode);
                }
                for (int i = 0; i < source.Count; i++)
                {
                    ImageConverter.ApplyMonochromeFilter(source[i], ret[i], threshold);
                }
                ImageUtility.Dispose(source);
            }

            return(ret);
        }