Summary: | Ppt background is black when using Apache POI to convert slide to image | ||
---|---|---|---|
Product: | POI | Reporter: | nanoticket2015 |
Component: | HSLF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED WONTFIX | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | All | ||
Attachments: |
ppt slide and generated image
Full Rendering sample |
Created attachment 35005 [details] Full Rendering sample Thanks for uploading your file from your stackoverflow question [1] I wasn't too far off with my guess there - the culprit seems to be the background transparency. I don't think, we should by default not support background transparency, therefore you might want to add those 3 lines to modify the transparent parts, before writing the image (taken from [2]) ... and use a ARGB colormodel. I'm closing this now as "won't fix" - feel free to reopen and convince me/us from the opposite ... [1] https://stackoverflow.com/questions/43973460 [2] https://stackoverflow.com/questions/36030307 see comment #1 |
Created attachment 35001 [details] ppt slide and generated image I am using the below code to convert ppt slides to image. BufferedImage imBuff = new BufferedImage(pgsize.width, (pgsize.height) * slides.size(), BufferedImage.TYPE_INT_RGB); Graphics g = imBuff.getGraphics(); Graphics2D graphics = img.createGraphics(); graphics.setRenderingHint(Drawable.FONT_MAP, fontMap); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); graphics.setPaint(TRANSPARENT); graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height)); slides.get(i).draw(graphics); g.drawImage(img, 0, i * (pgsize.height), null); For some .ppt files, the background appears as black. Does anyone know what is the reason and how to fix this? I suspect that the office software used to create the .ppt files might be a factor, but I am not able to confirm.