Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Copies an existing PageImage List, including pixel data.  PixelFormat,
 /// Resolution, and color depth are not affected.
 /// </summary>
 /// <param name="list">The list to copy.</param>
 /// <returns>The new page image list.</returns>
 private static List <PageImage> CreateDeepCopy(List <PageImage> list)
 {
     return(ImageUtility.LoadImage(list));
 }
Ejemplo n.º 3
0
 public static ImageOperationResult VerifyAllTiffFilesAndWriteFaxTiff(string inputFilePath, string outputFilePath, PaperSize paperSize, FaxQuality faxQuality)
 {
     return(ImageUtility.VerifyAllTiffFilesAndWriteFaxTiff(new string[] { inputFilePath }, outputFilePath, paperSize, faxQuality));
 }
Ejemplo n.º 4
0
 public static Image ConvertTo32BitBitmap(Bitmap bmp)
 {
     return(ConvertTo32BitBitmap(ImageUtility.LoadImage(bmp)));
 }
Ejemplo n.º 5
0
 public static Image ConvertTo32BitBitmap(Image image)
 {
     return(ConvertTo32BitBitmap(ImageUtility.LoadImage(image)));
 }
Ejemplo n.º 6
0
 public static void SaveAs32BitTiff(string inputFilePath, string outputFilePath)
 {
     ImageUtility.SaveAs32BitTiff(ImageUtility.LoadImage(inputFilePath), outputFilePath);
 }
Ejemplo n.º 7
0
 public static Image ConvertTo32BitBitmap(string inputFilePath)
 {
     return(ConvertTo32BitBitmap(ImageUtility.LoadImage(inputFilePath)));
 }
Ejemplo n.º 8
0
 public static void SaveAs32BitTiff(List <PageImage> pages, string outputFilePath)
 {
     ImageUtility.InternalSaveAs32BitTiff(pages, outputFilePath);
 }
Ejemplo n.º 9
0
 public static void SaveAs32BitTiff(Bitmap bmp, string outputFilePath)
 {
     ImageUtility.SaveAs32BitTiff(ImageUtility.LoadImage(bmp), outputFilePath);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Creates a new Page image list from the given Bitmap object.  Pages
 /// will be extracted into the Page image list if the source is multipage.
 /// </summary>
 /// <param name="image">The given Image object.</param>
 /// <param name="convertTo32Bit">Whether to coerce into a 32 bit</param>
 /// <returns>A new Page Image List</returns>
 public static List <PageImage> LoadImage(Image image, bool convertTo32Bit)
 {
     return(ImageUtility.InternalLoadImage(image, convertTo32Bit));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates a new Page image list from the given Bitmap object.  Pages
 /// will be extracted into the Page image list if the source is multipage.
 /// </summary>
 /// <param name="bmp">The given Bitmap object.</param>
 /// <param name="quality"></param>
 /// <returns>A new Page Image List</returns>
 public static List <PageImage> LoadImage(Bitmap bmp, FaxQuality quality)
 {
     return(ImageUtility.LoadImage((Image)bmp));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Creates a new Page image list from the given Bitmap object.  Pages
 /// will be extracted into the Page image list if the source is multipage.
 /// </summary>
 /// <param name="bmp">The given Bitmap object.</param>
 /// <param name="convertTo32Bit">Whether to coerce into a 32 bit</param>
 /// <returns>A new Page Image List</returns>
 public static List <PageImage> LoadImage(Bitmap bmp, bool convertTo32Bit)
 {
     return(ImageUtility.LoadImage((Image)bmp, convertTo32Bit));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Creates a new Page image list from the given page image list.
 /// </summary>
 /// <param name="pages">The given Page image list.</param>
 /// <returns>A new page image list</returns>
 public static List <PageImage> LoadImage(List <PageImage> pages)
 {
     return(ImageUtility.LoadImage(pages, true));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Creates a new Page image list from the given Bitmap object.  Pages
 /// will be extracted into the Page image list if the source is multipage.
 /// </summary>
 /// <param name="image">The given Bitmap object.</param>
 /// <returns>A new Page Image List</returns>
 public static List <PageImage> LoadImage(Image image)
 {
     return(ImageUtility.LoadImage(image, true));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Creates a new Page image list from the given Bitmap object.  Pages
 /// will be extracted into the Page image list if the source is multipage.
 /// </summary>
 /// <param name="bmp">The given Bitmap object.</param>
 /// <returns>A new Page Image List</returns>
 public static List <PageImage> LoadImage(Bitmap bmp)
 {
     return(ImageUtility.LoadImage(bmp, true));
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Creates a new Page image list from a file on disk. Pages
 /// will be extracted into the Page image list if the source is multipage.
 /// </summary>
 /// <param name="imageFileName">The source file.</param>
 /// <returns>A new Page Image List</returns>
 public static List <PageImage> LoadImage(string imageFileName)
 {
     return(ImageUtility.LoadImage(imageFileName, true));
 }