MRC image manipulation

Discussions about color detection and MRC support.
Post Reply
rlagrange
Posts: 27
Joined: Tue May 02, 2017 5:51 pm

MRC image manipulation

Post by rlagrange » Fri Sep 14, 2018 7:22 pm

Hello,

We are scanning a document, and we add the image in a pdf with a MRC compressio using GdPicturePdf :

Code: Select all

pdf.AddImageFromGdPictureImage(imageID, PdfAdvancedImageCompression.PdfAdvancedImageCompressionMRC);
Now later in my GdViewer interface, I want to convert the actual page to Grayscale.
Before MRC, I was looping the images of the pages, and convert each using GdPictureImaging.FxGrayScale :

Code: Select all

GdPictureImaging oGdPictureImaging = new GdPictureImaging();
            // Convertir chaque image de la page en Degradé de gris
            for (int image = 1; image <= _nativePdf.GetPageImageCount(); image++)
            {
                int imageID = _nativePdf.ExtractPageImage(image);
                // Conversion de l'image en dégradé
                oGdPictureImaging.FxGrayscale(imageID);
                // degrade B&W to bitonal
                //oGdPictureImaging.ColorDetection(imageID, true, true, true);
                // Remplacer l'image dans le PDF
                _nativePdf.ReplaceImage(_nativePdf.GetPageImageResName(image), imageID, false);
                oGdPictureImaging.ReleaseGdPictureImage(imageID);
            }
            oGdPictureImaging.Dispose();
Result : the colored parts of the picture are removed.
I am unable to find a way, even when using the imageMask parameter of the replaceImage function.

Can you please review my code, and give me a tip ?
I've attached my sample.

Thanks
Attachments
TOSEND.pdf
(74.73 KiB) Downloaded 1 time

User avatar
Loïc
Site Admin
Posts: 5597
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: MRC image manipulation

Post by Loïc » Mon Sep 17, 2018 8:18 pm

Hi,

Your approach is not correct. What I suggest is to rasterize the image in a new bitmap, then convert the rasterized bitmap to grayscale.

Please let me know if you need further information.

WIth best regards,

rlagrange
Posts: 27
Joined: Tue May 02, 2017 5:51 pm

Re: MRC image manipulation

Post by rlagrange » Mon Sep 24, 2018 12:10 pm

Hi Loïc,

While it could be okay for this specific sample, it will be counter productive for all others cases : mixed content text/image, etc, the result will be way bigger.
As my interface take scanned document, but also mixed files (word, pdf...), I need to have something which work in every case.

As your interface didn't allow us to manage MRC pictures as a single object, or alternatively to fully manage each MRC layers, we can't use MRC for now.

Ideally, the GdViewer could have a public method to manage all this complexity, and convert the selected pages to bitonal or grayscale while keeping the quality & compression choice.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest