Ejemplo n.º 1
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);
        }