We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

"Cannot create graphic object from indexed image format" when rendering slide on grayscale bitmap

Rendering a slide on a bitmap created as BufferedImage.TYPE_BYTE_GRAY. I’m using Aspose Slides for Java 20.3.

Sample stacktrace:

java.lang.RuntimeException: Cannot create graphic object from indexed image format
	at com.aspose.slides.internal.ey.throws.<init>(Unknown Source)
	at com.aspose.slides.internal.ey.catch.do(Unknown Source)
	at com.aspose.slides.internal.ey.catch.do(Unknown Source)
	at com.aspose.slides.Slide.renderToGraphics(Unknown Source)
	at aspose.SlidesTest.testFailureToRenderOnGrayscale(SlidesTest.java:61)

Sample code:

File slides = new File("test-resources/Test Presentation.pptx");
Presentation doc = new Presentation(slides.getAbsolutePath());
ISlide slide = doc.getSlides().get_Item(0);
//prepare image
BufferedImage img = new BufferedImage(200, 200, BufferedImage.TYPE_BYTE_GRAY);
NotesCommentsLayoutingOptions ncl = new NotesCommentsLayoutingOptions();
//render image
Graphics2D gr = img.createGraphics();
gr.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
gr.clearRect(0, 0, img.getWidth(), img.getHeight());
//the following line throws an exception in Aspose Slides 20.3
slide.renderToGraphics(ncl, gr, img.getWidth(), img.getHeight());

Any powerpoint file can be used.


I have worked over the issue shared by you and have created a ticket with ID SLIDESJAVA-38098 in our issue tracking system to further investigate and resolve it. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

1 Like

The issues you have found earlier (filed as SLIDESJAVA-38098) have been fixed in this update.