You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by John Hewson <jo...@jahewson.com> on 2014/03/07 14:58:36 UTC

Re: pdfbox patch proposal

Hi Andreas

Thanks for contacting us, colour space handing code has recently undergone a few
changes and there are probably a few cases where further optimisations are possible.

Unfortunately we can’t return a non-RGB from getRGBImage(). All images returned
need to use an RGB colour model in their BufferedImage to avoid slow drawing
operations in Graphics2D when they are rendered to the page. For 1bit images you’re 
not going to encounter this problem but for CMYK images with an ICC profile the effect
is several orders of magnitude.

I presume that your 1bit images use the DeciceGray colour space, so try rewriting the
PDDeviceGray#toRGBImage method instead, there may be a way of doing the 1bit colour
conversion faster, as long as the BufferedImage returned is created by calling:

new BufferedImage(raster.getWidth(), raster.getHeight(), BufferedImage.TYPE_INT_RGB);

instead of using a custom colour model, then we could potentially include it in PDFBox.

Thanks,

-- John

On 6 Mar 2014, at 23:09, Andreas Weber <se...@gmail.com> wrote:

> HI!
> 
> We managed to speed up reading certain pdf files (with lots of 1bit images inside) a lot by not reading them bit by bit and avoiding costly color convertops (as the images are black white anyway).
> maybe you find the useful:
> 
> https://github.com/patric42/pdfbox/commit/509c91381424fa4a94fbd4ba68e9597a16f15492
> 
> best regards
> 
> Andreas