[ 
https://issues.apache.org/jira/browse/PDFBOX-2092?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14019857#comment-14019857
 ] 

Petr Slaby commented on PDFBOX-2092:
------------------------------------

Btw, regardless of Component or Sampled image model, I would suggest to change 
SampledImageReader#from8bit() so that it reads the data in chunks, instead of 
reading the whole input into a byte buffer using IOUtils.toByteArray(). A full 
page image can have something like 30 or 40 MB of raw data, it is a waste to 
create an additional copy of it. You could change it e.g. like this (buffer 
size is multiple of numComponents so that it can be read in the outer loop to 
avoid the if(idx == source.length) in the inner loop):

{noformat}
private static BufferedImage from8bit
...
            int max = width * height;
            byte[] source = new byte[4096 * numComponents];
            int idx = source.length;
            for (int i = 0; i < max; i++)
            {                
                if(idx == source.length) {
                    idx = 0;
                    input.read(source);
                }
                for (int c = 0; c < numComponents; c++)
                {
                    banks[c][i] = source[idx]; 
                    idx++; 
                }
            }
...
{noformat}

> Very slow rendering of scanned document
> ---------------------------------------
>
>                 Key: PDFBOX-2092
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2092
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: Rendering
>    Affects Versions: 2.0.0
>         Environment: Win7 x64 EN
> JDK6,JDK7,JDK8
>            Reporter: Juraj Lonc
>         Attachments: SCAN_20140522_160457490_page2.pdf
>
>
> It takes extremely long to render this file to image.
> Depends on computer but it can take 15s+ to render 1 page.
> When I skip drawing of inserted image /Im0, then rendering is fast. So there 
> is something wrong with drawing that image in
> {code}
> PageDrawer.drawImage(Image awtImage, AffineTransform at)
> {code}
> when I comment out line 
> {code}
> graphics.drawImage(awtImage, imageTransform, null);
> {code}
> then rendering process takes 6s



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to