PXCV_DrawPageToDIBSection too slow in high dpi/sizes

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

csterg
User
Posts: 15
Joined: Fri Mar 28, 2014 11:34 pm

PXCV_DrawPageToDIBSection too slow in high dpi/sizes

Post by csterg »

Hello,
I am evaluating the viewer DLL alongside a similar product (foxit).
After several tests and measurements, it seems that the xtrack dll is at least 3 times slower in higher DPIs (e.g. exporting at 300dpi or ~300% zoom). Is there a possibility that I am using the PXCV_DrawPageToDIBSection() wrongly?
Here is my (delphi) code:

Code: Select all

  r := Types.Rect(0, 0, w, h);
  pParams.WholePageRect := @r;
  pParams.DrawRect := nil;
  pParams.Flags := pxvrpf_Rotate_NoRotate OR $0040;
  pParams.RenderTarget := pxvrm_Exporting;

  Res := PXCV_DrawPageToDIBSection(pDocument, PageNum, @pParams, 0, $00ffffff, @bmp, 0, 0);
  ...
It seems that as I increase the dpi/zoom level, the rendering speed increases proportionately.

TIA
Costas
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: PXCV_DrawPageToDIBSection too slow in high dpi/sizes

Post by Stefan - PDF-XChange »

Hello Costas,

I've just checked with one of my colleagues from the dev team and as he commented - it's normal when you have more pixels to render the job to take longer. It is also not a linear increase in the processing time when you e.g. double the pixels it might take a bit longer than x2 the time to complete the job.

Also my colleague commented that PXCV_DrawPageToDIBSection is not a good choise for high DPI cases.
Why do you need to use 300 DPI? If this is for printing, it will be much better to use PXCV_DrawPageToDC and set the pxvrpf_UseVectorRenderer flag instead.

Regards,
Stefan
csterg
User
Posts: 15
Joined: Fri Mar 28, 2014 11:34 pm

Re: PXCV_DrawPageToDIBSection too slow in high dpi/sizes

Post by csterg »

I need to rasterize PDF files in order to export them later as TIF files. I have the code to make a tif, yet i do require the fastest way to rasterize the PDF in resolutions about 200-300dpi.
What is the fastest method to do so?
Costas
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: PXCV_DrawPageToDIBSection too slow in high dpi/sizes

Post by Stefan - PDF-XChange »

Hello Costas,

Then please try the PXCV_DrawPageToIStream method instead.

Regards,
Stefan
csterg
User
Posts: 15
Joined: Fri Mar 28, 2014 11:34 pm

Re: PXCV_DrawPageToDIBSection too slow in high dpi/sizes

Post by csterg »

Hello Stefan,
I used the PXCV_DrawPageToDC on a memory DC with a pre-created DIBSection and works really fast when using the VectorRenderer!
Thank you for your immediate support,
Costas
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: PXCV_DrawPageToDIBSection too slow in high dpi/sizes

Post by Stefan - PDF-XChange »

:)
csterg
User
Posts: 15
Joined: Fri Mar 28, 2014 11:34 pm

Re: PXCV_DrawPageToDIBSection too slow in high dpi/sizes

Post by csterg »

Hello Stefan,
I just realized that using the pxvrpf_UseVectorRenderer option does no anti-aliasing, making the output useful only for printing and NOT viewing on screen. Unfortunately this is not an option for me, so I am back to my original question where I am having the same performance issue when rendering for viewing (3x slower than other product).
Is there something else I can look into? I do nee the anti-aliasing option there, no question about that.
Costas
csterg
User
Posts: 15
Joined: Fri Mar 28, 2014 11:34 pm

Re: PXCV_DrawPageToDIBSection too slow in high dpi/sizes

Post by csterg »

I also tried PXCV_DrawPageToIStream but the results are worse (by the way: this method is not even in the delphi .pas files...)
Costas
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: PXCV_DrawPageToDIBSection too slow in high dpi/sizes

Post by Stefan - PDF-XChange »

Hi Costas,

Then did you try to use
PXCV_DrawPageToDC on a memory DC with a pre-created DIBSection
but using Raster Renderer instead?

Regards,
Stefan
csterg
User
Posts: 15
Joined: Fri Mar 28, 2014 11:34 pm

Re: PXCV_DrawPageToDIBSection too slow in high dpi/sizes

Post by csterg »

Tracker Supp-Stefan wrote:Hi Costas,

Then did you try to use
PXCV_DrawPageToDC on a memory DC with a pre-created DIBSection
but using Raster Renderer instead?

Regards,
Stefan
yes i tried that, performace is identical as when using the PXCV_DrawPageToDIBSection method
Costas
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3586
Joined: Thu Jul 08, 2004 10:36 pm

Re: PXCV_DrawPageToDIBSection too slow in high dpi/sizes

Post by Ivan - Tracker Software »

There are several factors which may have an influence on rendering speed.

First of all it is the dimension of the resulting image.
Secondly - it is the flag pxvrpf_UseVectorRenderer. When this flag is set we are using GDI for rendering (as during printing to a physical printer).
In most cases it is the fastest way, but PDF and GDI graphics models are different and not everything needed to generate a satisfactory PDF is supported by the GDI, and sometimes rasterization is required.

Rasterization is also in used when the flag pxvrpf_UseVectorRenderer is not specified.
The rasterization is sent to an internal buffer and then the content of this buffer is transferred from the DC to PXCV_DrawPageToDIBSection or PXCV_DrawPageToDC functions.

PXCV_DrawPageToIStream function should be faster because it avoids translation from the internal buffer to the DC and saves to the TIFF/JPG/PNG stream directly from this buffer.

HTH
PDF-XChange Co Ltd. (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
csterg
User
Posts: 15
Joined: Fri Mar 28, 2014 11:34 pm

Re: PXCV_DrawPageToDIBSection too slow in high dpi/sizes

Post by csterg »

Hello Ivan and thank you for the information and your support.
I understand all you are saying, yet the result seems not satisfactory. I am using the XTracker PDF Viewer for my personal needs (I find it fast), but for the reason I need the SDK, it does not seem satisfactory.
Costas
User avatar
Lzcat - Tracker Supp
Site Admin
Posts: 677
Joined: Thu Jun 28, 2007 8:42 am

Re: PXCV_DrawPageToDIBSection too slow in high dpi/sizes

Post by Lzcat - Tracker Supp »

Can you try to use PXCV_DrawPageToDC on a memory DC with a pre-created DIBSection (using raster renderer) and not draw all page at once, but slice it to smaller parts, with dimensions not greater than 5000 pixels?
For example you need render image with width 7000 and height 11000. Than create DC with bitmap of needed size, and call PXCV_DrawPageToDC six times with following parameters:
WholePageRect is same for all calls - {0, 0, 7000, 11000}
DrawRect is different for each call:

Code: Select all

1) {    0,     0, 4000,  4000}
2) { 4000,     0, 7000,  4000}
3) {    0,  4000, 4000,  8000}
4) { 4000,  4000, 7000,  8000}
5) {    0,  8000, 4000, 11000}
6) { 4000,  8000, 7000, 11000}
All other parameters should be same.
Victor
Tracker Software
Project manager

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
csterg
User
Posts: 15
Joined: Fri Mar 28, 2014 11:34 pm

Re: PXCV_DrawPageToDIBSection too slow in high dpi/sizes

Post by csterg »

I tried this already because i read it in another post in the forum. There is a slight improvement; yet the average output i need is about 3000X3000 (Letter size page in 300dpi: 8.5X11inch)
Costas
User avatar
Lzcat - Tracker Supp
Site Admin
Posts: 677
Joined: Thu Jun 28, 2007 8:42 am

Re: PXCV_DrawPageToDIBSection too slow in high dpi/sizes

Post by Lzcat - Tracker Supp »

Hi Costas.
Sorry, we have no more ways to improve performance with the current version of SDK. We are working on new version, in which we can try to make improvements in speed however we cannot provide a firm date for this at this time and if your needs are pressing then realistically for now I am afraid we do not have a solution to your needs.
Victor
Tracker Software
Project manager

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
csterg
User
Posts: 15
Joined: Fri Mar 28, 2014 11:34 pm

Re: PXCV_DrawPageToDIBSection too slow in high dpi/sizes

Post by csterg »

Lzcat - Tracker Supp wrote:Hi Costas.
Sorry, we have no more ways to improve performance with the current version of SDK. We are working on new version, in which we can try to make improvements in speed however we cannot provide a firm date for this at this time and if your needs are pressing then realistically for now I am afraid we do not have a solution to your needs.
Thank you for the update. I will try to stay in the loop and look forward to it
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: PXCV_DrawPageToDIBSection too slow in high dpi/sizes

Post by John - Tracker Supp »

Will keep you posted if anything leads to further assistance in this area.

cheers
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com