Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.0.25
-
None
-
None
-
None
Description
Due to changes for better image quality when images are scaled down in https://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java?r1=1877290&r2=1877289&pathrev=1877290 the attached PDF renders much slower.
I propose to replace image.gerScaledInstance by
public BufferedImage getRescaledImage( BufferedImage image, int w, int h ) throws IOException { float scaleW = w / (( float )image.getWidth()); float scaleH = h / (( float )image.getHeight()); if(scaleW < .5f || scaleH < .5f){ int nextW = scaleW <.5f ? ( int )Math.ceil( image.getWidth() / 2.0 ) : w; int nextH = scaleH <.5f ? ( int )Math.ceil( image.getHeight() / 2.0 ) : h; image = getRescaledImage( image, nextW, nextH ); } int type = (image.getTransparency() == Transparency.OPAQUE) ? BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB; BufferedImage scaled = new BufferedImage( w, h, type ); Graphics2D g = scaled.createGraphics(); g.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR ); g.drawImage( image, 0, 0, w, h, null ); return scaled; }
While this implementations seems to be a bit slower than getScaledInstance, the call to graphics.drawImage with the resulting BufferedImage seems to be significantly faster than drawing the ToolkitImage.
Attachments
Attachments
Issue Links
- relates to
-
PDFBOX-4516 PDFBox text and images are blurry even after rendering with high DPI
- Closed