Hi, is there a way to programmatically set the transparency of a frame? (the equivalent of the uploaded picture). I have a text place holder on a layout that is filled with a picture. occasionally, on presentation slides, this needs to be adjusted to be 10% transparent
Screenshot 2021-09-23 095646.png (13.2 KB)
Thanks
@JamesDriscoll,
Thank you for posting the query. So that I can make sure I understand you correctly, could you please share a presentation file with an example of the text placeholder you mentioned?
@JamesDriscoll,
Thank you for the shape example. Unfortunately, I have not found the ability to change the transparency of the picture filling the shape. I logged the issue with ID SLIDESJAVA-38638 in our tracking system. Our development team will consider this feature. We will inform you of any progress.
@JamesDriscoll,
Our development team investigated the issue. To set transparency for the filling picture, please use the next code example:
Presentation presentation = new Presentation(folderPath + "example.pptx");
for(IShape shape : presentation.getSlides().get_Item(1).getShapes())
{
if (shape instanceof IAutoShape)
{
IAutoShape picture = (IAutoShape)shape;
IImageTransformOperationCollection operationCollection = picture.getFillFormat().getPictureFillFormat().getPicture().getImageTransform();
for (int i = 0; i < operationCollection.size(); i++)
{
if(operationCollection.get_Item(i) instanceof AlphaModulateFixed)
{
AlphaModulateFixed alphaModulate = (AlphaModulateFixed)operationCollection.get_Item(i);
float currentValue = 100 - alphaModulate.getAmount();
System.out.println("Current value: " + currentValue);
int alphaValue = 40;
alphaModulate.setAmount(100 - alphaValue);
}
}
}
}
presentation.save(folderPath + "example_out.pptx", SaveFormat.Pptx);
API Reference: AlphaModulateFixed Class, ImageTransformOperationCollection Class
1 Like