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

Daniel Gredler commented on PDFBOX-4300:
----------------------------------------

[~rototor] and [~tilman]: Great insights, thanks!

I do wonder if a fast path for {{TYPE_BYTE_GRAY}} and {{TYPE_BYTE_BINARY}} 
{{BufferedImage}} instances might be useful, as long as there are appropriate 
stride ({{height * width * bpc / 8 == pixels.length}}) and buffer type 
({{image.getColorModel().getTransferType() == DataBuffer.TYPE_BYTE}}) checks – 
especially since it seems that standard bitonal and grayscale {{BufferedImage}} 
instances that are manually instantiated seem to pass these checks, and the 
images are encoded twice as fast this way (I didn't measure memory impact, 
unfortunately). I'm not sure if the color profile / gamma curve issue is a real 
problem or just something that breaks the tests as currently implemented. 
However, I'm going to use this approach locally as I play around, and will 
report back if I run into any unexpected problems that haven't been discussed 
yet.

> Reduce im memory buffers when creating grayscale images
> -------------------------------------------------------
>
>                 Key: PDFBOX-4300
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4300
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: PDModel
>    Affects Versions: 2.0.11
>            Reporter: Jesse Long
>            Priority: Minor
>              Labels: optimization
>         Attachments: PDFBOX-4300-1.patch
>
>
> LosslessFactory uses ByteArrayOutputStreams when creating PDF image data. 
> First, it creates a BAOS in which to store the data, then a BAOS in which to 
> store the flate encoded data. Finally the flate encoded data is written to 
> the PDImageXObject's stream.
> We could instead create an empty PDStream, give it a filter, and write the 
> image data directly into the stream. We then instantiate a PDImageXObject 
> giving it the already created stream.
> This would dramatically reduce RAM requirement if a scratchfile is in play.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to