|Summary:||Ppt background is black when using Apache POI to convert slide to image|
|Component:||HSLF||Assignee:||POI Developers List <dev>|
ppt slide and generated image
Full Rendering sample
Description nanoticket2015 2017-05-22 08:34:24 UTC
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.
Comment 1 Andreas Beeker 2017-05-23 23:57:28 UTC
Created attachment 35005 [details] Full Rendering sample Thanks for uploading your file from your stackoverflow question  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 ) ... 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 ...  https://stackoverflow.com/questions/43973460  https://stackoverflow.com/questions/36030307