Page 1 of 1

Convert To BW

Posted: Thu Mar 29, 2018 9:12 pm
by jeffp
I have an IIXC_Page object that is a gray scale image. I need to convert it into a black and white image.

Here is what I'm using currently

var
APage: IIXC_Page;
begin
APage.ConvertToFormat(PageFormat_1Indexed);
APage.Set_FmtInt(FP_ID_ITYPE, 1);
APage.Set_FmtInt(FP_ID_BPP, 1);

However, the last line that sets the BPP to 1 inverts the image so what was white is now black.

Is this the correct way to covert a gray scale image to black and white? If not, how would you suggest I accomplish this with the IIXC_Page object?

--Jeff

Re: Convert To BW

Posted: Fri Mar 30, 2018 10:11 am
by Sasha - Tracker Dev Team
Hello Jeff,

Are you using the Editor SDK or Core API?

Cheers,
Alex

Re: Convert To BW

Posted: Fri Mar 30, 2018 12:19 pm
by jeffp
I need to be able to make this conversion via the API in code. Again using the IIXC_Page object.

Re: Convert To BW

Posted: Mon Apr 02, 2018 8:57 am
by Sasha - Tracker Dev Team
Hello Jeff,

Can you please give us a full sample, that does this conversion and also, that will give us the same presentation of the result that you have (to investigate the inverse part), because this code alone is not enough to make a correct judgement.

Cheers,
Alex

Re: Convert To BW

Posted: Wed May 16, 2018 3:24 pm
by jeffp
I'm having a hard time finding the sample file that wasn't working.

Can I just ask what calls you would make to turn a GrayScale or Color image into a BW image?

--Jeff

Re: Convert To BW

Posted: Thu May 17, 2018 12:28 pm
by Sasha - Tracker Dev Team
Hello Jeff,

We've implemented the IIXC_Page::ReduceColorsFixedPalette method that will allow you to set the needed colors palette (in your case the Black and White colors) and make the image BW. This will be available from the next release (326).
PS: No release ETA yet.

Cheers,
Alex

Re: Convert To BW

Posted: Thu May 17, 2018 2:13 pm
by jeffp
Thanks.

Re: Convert To BW

Posted: Thu May 17, 2018 2:32 pm
by Sasha - Tracker Dev Team
:)

Re: Convert To BW

Posted: Thu Jan 03, 2019 8:24 pm
by jeffp
Ok The call is defined as

function ReduceColorsFixedPalette(pFixedPalette: PSafeArray; nDitherMethod: IXC_DitherMethod): HResult; stdcall;

Can you help me with what to set for pFixedPallette to turn the page into a BW image

APage.ReduceColorsFixedPalette(???, Dither_none);

Also, how does ReduceColorsAdaptive compare to ReduceColorsFixedPalette?

Again, I'm using Delphi.

--Jeff

Re: Convert To BW

Posted: Fri Jan 04, 2019 4:00 pm
by Sasha - Tracker Dev Team
Hello Jeff,

You should have something like this:

Code: Select all

static RGBQUAD bw_palette[] = {{0, 0, 0, 0}, {0xFF, 0xFF, 0xFF, 0}};
I will try to write a code sample tomorrow.

Cheers,
Alex

Re: Convert To BW

Posted: Fri Jan 04, 2019 4:15 pm
by jeffp
Yes. A Delphi Code sample would be great. Again, lookiing for the optimal way to convert an image to black and white.

You have a APage.ToGrayscale procedure currently. Maybe you should add APage.ToBW

Thanks again.

--Jeff

Re: Convert To BW

Posted: Tue Jan 08, 2019 9:54 am
by Sasha - Tracker Dev Team
Hello Jeff,

I've update a description of this method here:
https://sdkhelp.tracker-software.com/vi ... xedPalette
And also, I've made a working sample (4.12. ChangeAllOfTheImagesToBlackAndWhite) in the CoreAPIDemo project available from here:
https://github.com/tracker-software/PDFCoreSDKExamples

Cheers,
Alex