MRC image manipulation

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

MRC image manipulation

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


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é
                // degrade B&W to bitonal
                //oGdPictureImaging.ColorDetection(imageID, true, true, true);
                // Remplacer l'image dans le PDF
                _nativePdf.ReplaceImage(_nativePdf.GetPageImageResName(image), imageID, false);
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.

(74.73 KiB) Downloaded 94 times

User avatar
Site Admin
Posts: 5812
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: MRC image manipulation

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


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,

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.

Posts: 436
Joined: Wed Nov 22, 2017 9:52 am

Re: MRC image manipulation

Post by Gabriela » Thu Jan 17, 2019 10:13 am


Here we can offer you a new method ReplaceImageMRC() introduced in the 14.1.1 version of the toolkit: ... geMRC.html
It can be useful for image-based pages.
Kind regards,

GdPicture Team

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest