Created attachment 27840 [details] PPT with a slide with shapes grouped Slide.draw throws java.lang.OutOfMemoryError in some slides with grouped shapes. How to reproduce: - Download the attached PPT (TesteAgrupado.ppt) - Run org.apache.poi.hslf.examples.PPT2PNG TesteAgrupado.ppt If you open the PPT, ungroup the shapes within the first slide and run the PPT2PNG again, no error will occur! I´ve already tried to increase the heap memory size but got the same error. The output and stack trace: Rendering slide 1 Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.awt.image.DataBufferInt.<init>(Unknown Source) at java.awt.image.Raster.createPackedRaster(Unknown Source) at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknow n Source) at sun.awt.image.ImageRepresentation.createBufferedImage(Unknown Source) at sun.awt.image.ImageRepresentation.setPixels(Unknown Source) at java.awt.image.AreaAveragingScaleFilter.accumPixels(Unknown Source) at java.awt.image.AreaAveragingScaleFilter.setPixels(Unknown Source) at sun.awt.image.OffScreenImageSource.sendPixels(Unknown Source) at sun.awt.image.OffScreenImageSource.produce(Unknown Source) at sun.awt.image.OffScreenImageSource.addConsumer(Unknown Source) at sun.awt.image.OffScreenImageSource.startProduction(Unknown Source) at java.awt.image.FilteredImageSource.startProduction(Unknown Source) at sun.awt.image.ImageRepresentation.startProduction(Unknown Source) at sun.awt.image.ImageRepresentation.drawToBufImage(Unknown Source) at sun.java2d.pipe.DrawImage.copyImage(Unknown Source) at sun.java2d.SunGraphics2D.drawImage(Unknown Source) at sun.java2d.SunGraphics2D.drawImage(Unknown Source) at org.apache.poi.hslf.blip.BitmapPainter.paint(BitmapPainter.java:65) at org.apache.poi.hslf.usermodel.PictureData.draw(PictureData.java:230) at org.apache.poi.hslf.model.Picture.draw(Picture.java:268) at org.apache.poi.hslf.model.ShapeGroup.draw(ShapeGroup.java:289) at org.apache.poi.hslf.model.Slide.draw(Slide.java:433) at org.apache.poi.hslf.examples.PPT2PNG.main(PPT2PNG.java:95)
Should be fixed in r1293561 Yegor
Why Status is RESOLVED? I didn't find the solution! Please, can show me? Thanks
Did you try the latest build from trunk? Does it still throw OutOfMemory for the attached file? (In reply to comment #2) > Why Status is RESOLVED? I didn't find the solution! > Please, can show me? > > Thanks
OK, i saw it, but i don't understand how can I get the Picture object(parent) in BitmapPainter.paint(Graphics2D graphics, PictureData pict, Picture parent) method? I put my method that returns a list of strings(the BufferedImage converted in base64) --> one string for one slide /***************************************************/ private List<String> obtainSlidesFromPPT(InputStream is) { SlideShow ppt = null; List<String> returnList = new LinkedList<String>(); try { ppt = new SlideShow(is); is.close(); Dimension pgsize = ppt.getPageSize(); PictureData [] pd = ppt.getPictureData(); int nSlides = pd.length; for (int i = 0; i < nSlides; i++) { PictureData pict = pd[i]; BufferedImage img = ImageIO.read(new ByteArrayInputStream(pict.getData())); Graphics2D graphics = img.createGraphics(); //Rectangle anchor = parent.getLogicalAnchor2D().getBounds(); graphics.drawImage(img, anchor.x, anchor.y, anchor.width, anchor.height, null); graphics.dispose(); returnList.add(covertBufferedImageInBase64String(img)); } } catch (IOException ioe) { System.err.println(ioe.getMessage()); } return returnList; } /***************************************************/ (In reply to comment #3) > Did you try the latest build from trunk? Does it still throw OutOfMemory for > the attached file? > > (In reply to comment #2) > > Why Status is RESOLVED? I didn't find the solution! > > Please, can show me? > > > > Thanks
To get Picture objects from a slide you need to iterate over the shapes and check if a shape is an instance of Picture, see example at http://poi.apache.org/slideshow/how-to-shapes.html#Pictures (In reply to comment #4) > OK, i saw it, but i don't understand how can I get the Picture > object(parent) in BitmapPainter.paint(Graphics2D graphics, PictureData pict, > Picture parent) method? > I put my method that returns a list of strings(the BufferedImage converted > in base64) --> one string for one slide > > /***************************************************/ > private List<String> obtainSlidesFromPPT(InputStream is) { > SlideShow ppt = null; > List<String> returnList = new LinkedList<String>(); > try { > ppt = new SlideShow(is); > is.close(); > Dimension pgsize = ppt.getPageSize(); > PictureData [] pd = ppt.getPictureData(); > int nSlides = pd.length; > for (int i = 0; i < nSlides; i++) { > PictureData pict = pd[i]; > BufferedImage img = ImageIO.read(new > ByteArrayInputStream(pict.getData())); > Graphics2D graphics = img.createGraphics(); > //Rectangle anchor = parent.getLogicalAnchor2D().getBounds(); > graphics.drawImage(img, anchor.x, anchor.y, anchor.width, anchor.height, > null); > graphics.dispose(); > returnList.add(covertBufferedImageInBase64String(img)); > } > } catch (IOException ioe) { > System.err.println(ioe.getMessage()); > } > return returnList; > } > /***************************************************/ > > > (In reply to comment #3) > > Did you try the latest build from trunk? Does it still throw OutOfMemory for > > the attached file? > > > > (In reply to comment #2) > > > Why Status is RESOLVED? I didn't find the solution! > > > Please, can show me? > > > > > > Thanks