Bug 61112 - Ppt background is black when using Apache POI to convert slide to image
Summary: Ppt background is black when using Apache POI to convert slide to image
Alias: None
Product: POI
Classification: Unclassified
Component: HSLF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2017-05-22 08:34 UTC by nanoticket2015
Modified: 2017-05-23 23:58 UTC (History)
0 users

ppt slide and generated image (55.01 KB, application/x-zip-compressed)
2017-05-22 08:34 UTC, nanoticket2015
Full Rendering sample (2.25 KB, text/x-java)
2017-05-23 23:57 UTC, Andreas Beeker

Note You need to log in before you can comment on or make changes to this bug.
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.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
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 [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
Comment 2 Andreas Beeker 2017-05-23 23:58:25 UTC
see comment #1