Page 1 of 1

MRC image manipulation

Posted: Fri Sep 14, 2018 7:22 pm
by rlagrange
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

Re: MRC image manipulation

Posted: Mon Sep 17, 2018 8:18 pm
by Loïc
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,

Re: MRC image manipulation

Posted: Mon Sep 24, 2018 12:10 pm
by rlagrange
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.

Re: MRC image manipulation

Posted: Thu Jan 17, 2019 10:13 am
by Gabriela
Hello,

Here we can offer you a new method ReplaceImageMRC() introduced in the 14.1.1 version of the toolkit:
https://www.gdpicture.com/guides/gdpicture/web ... geMRC.html
It can be useful for image-based pages.