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

Free Support Forum - aspose.com

Slide Preview: Fill Pattern for Rotated Shapes Is Rotated Incorrectly

Fill Patterns for rotated shapes have been missing and it was announced to be fixed in Aspose Slides Java 20.3 ( SLIDESJAVA-38008). Unfortunately, it was not resolved properly.

Now the pattern is there, but is rotated together with the shape. This behavior is not equal to the behavior in Powerpoint. In Powerpoint, the fill pattern is never rotated, but always stays the same. You can already observe this behavior in the example I provided back then.

And also, I observed a second issue, that the fill pattern is scaled together with the image size, which is also not the case in Powerpoint and also not the case for unrotated shapes in the thumbnail. This second issue is observable if, for example, scale factors 2 are used.

So my expectation is that the fill pattern looks the same in the thumbnail as it displayed in Powerpoint:
it should not be rotated and it should not be stretched when the shape size or slide size is changed.

Tested with Aspose Slides Java 20.5.

IncorrectFillPatternInThumbnail.png (66.4 KB)

Code to reproduce:

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.imageio.ImageIO;

import com.aspose.slides.FillType;
import com.aspose.slides.IAutoShape;
import com.aspose.slides.IColorFormat;
import com.aspose.slides.IShapeFrame;
import com.aspose.slides.ISlide;
import com.aspose.slides.NullableBool;
import com.aspose.slides.PatternStyle;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import com.aspose.slides.ShapeFrame;
import com.aspose.slides.ShapeType;

public class Main {

	public static void main(String[] args) {
		final Presentation presentation = new Presentation();
		final ISlide slide = presentation.getSlides().get_Item(0);

		addTriangle(slide, 60);

		final IAutoShape rotated90 = addTriangle(slide, 220);
		rotate(rotated90, 90);

		final IAutoShape rotated270 = addTriangle(slide, 380);
		rotate(rotated270, 270);


		final File pngFile = new File("IncorrectFillPatternInThumbnail.png");
		try (final FileOutputStream outputStream = new FileOutputStream(pngFile)) {
			System.out.println("Writing file " + pngFile.getAbsolutePath());
			ImageIO.write(slide.getThumbnail(2, 2), "png", outputStream);
		} catch (final IOException e) {
			e.printStackTrace();
		}

		final File pptxFile = new File("IncorrectFillPatternInThumbnail.pptx");
		System.out.println("Writing file " + pptxFile.getAbsolutePath());
		try (final FileOutputStream outputStream = new FileOutputStream(pptxFile)) {
			presentation.save(outputStream, SaveFormat.Pptx);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	private static IAutoShape addTriangle(final ISlide slide, final float y) {
		final IAutoShape shape = slide.getShapes().addAutoShape(ShapeType.Triangle, 310, y, 100, 100);
		final IColorFormat foreColor = slide.getPresentation().getMasterTheme().getColorScheme().getAccent1();
		final IColorFormat backColor = slide.getPresentation().getMasterTheme().getColorScheme().getLight1();
		shape.getFillFormat().setFillType(FillType.Pattern);
		shape.getFillFormat().getPatternFormat().setPatternStyle(PatternStyle.Vertical);
		shape.getFillFormat().getPatternFormat().getForeColor().copyFrom(foreColor);
		shape.getFillFormat().getPatternFormat().getBackColor().copyFrom(backColor);
		return shape;
	}

	private static void rotate(final IAutoShape shape, final float rotationAngle) {
		final IShapeFrame frame = shape.getFrame();
		final float x = frame.getX() - (frame.getHeight() - frame.getWidth()) / 2;
		final float y = frame.getY() - (frame.getWidth() - frame.getHeight()) / 2;
		shape.setFrame(new ShapeFrame(x, y, frame.getHeight(), frame.getWidth(), NullableBool.False, NullableBool.False, rotationAngle));
	}
}

@pstoehrer,

I have worked with the sample code shared and have also observe the description provided. A ticket with ID SLIDESJAVA-38111 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.