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

Free Support Forum - aspose.com

Save conector as image

Hi. I am using Aspose Slides for Java (v 17.3) to parse and import shapes. I use the following generic method to import some shapes as images.

protected ImageShape getShapeImage(IShape iShape, Rectangle2D anchor, int zIndex) throws IOException {
	BufferedImage image = iShape.getThumbnail(ShapeThumbnailBounds.Appearance, 1f, 1f);
	if (image != null) {
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
		ImageIO.write(image, FILE_PNG_EXTENSION, byteArrayOutputStream);
		byteArrayOutputStream.flush();
		byteArrayOutputStream.close();
		return new ImageShape(generateFileName(FILE_PNG_EXTENSION), byteArrayOutputStream.toByteArray(), anchor, zIndex);
	}
	return new ImageShape(generateFileName(FILE_PNG_EXTENSION), null, anchor, zIndex);
}

ImageShape is just a POJO encapsulating the data.

For some connectors however the image quality is not good. Is there a way to improve this (see attached ppt)?
arrows.zip (19.7 KB)

Thank you,

Dragos

Hi Dragos,

Thanks for inquiring Aspose.Slides.

I have observed the information shared by you and request you to please first try using Aspose.Slides for Java 17.5 on your end. If there is still an issue then please share the generated output file along with Java and Operating System details used on your end. I will be able to investigate the issue further on my end on provision of requested information.

Many Thanks,

Mudassir Fayyaz
Aspose - File Format APIs

Keep in touch! We’re on Twitter and Facebook

Hi Mudassir.

Upgrading to version 17.5 didn’t really help, but anyway, it was a good reminder to use the latest version.

The problem was actually here - in case someone faces the same
BufferedImage image = iShape.getThumbnail(ShapeThumbnailBounds.Appearance, 1f, 1f);
Changing this to
BufferedImage image = iShape.getThumbnail(ShapeThumbnailBounds.Appearance, 2f, 2f);
significantly improve the quality of the image

Thanks and best regards,

Dragos

Hi Dragos,

Thanks for your feedback. Yes, when you increase the scaling factor while generating the slide or shape thumbnail, it improves the quality by increasing pixels. It also increase the image size as well. Please share, if I may still help you further in this regard.

Many Thanks,

Mudassir Fayyaz