Free Support Forum - aspose.com

Aspose.Slides添加形状,用图片填充之后,如何设置图片的透明度

// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
try {
// Get the first slide
ISlide sld = pres.getSlides().get_Item(0);

// Add AutoShape of rectangle type
IShape shp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 50, 150, 75, 150);

// Set the fill type to Picture
shp.getFillFormat().setFillType(FillType.Picture);

// Set the picture fill mode
shp.getFillFormat().getPictureFillFormat().setPictureFillMode(PictureFillMode.Tile);

// Set the picture
IPPImage imgx = pres.getImages().addImage(new FileInputStream(new File("aspose1.jpg")));
shp.getFillFormat().getPictureFillFormat().getPicture().setImage(imgx);

// Write the PPTX file to disk
pres.save("RectShpPic.pptx", SaveFormat.Pptx);

} catch (IOException e) {
} finally {
if (pres != null) pres.dispose();
}

@lvyoufang

您可以在示例代码中尝试使用以下语句吗

    IShape shape = sld.getShapes().get_Item(0);
    shape.getFillFormat().getPictureFillFormat().getPicture().getImageTransform().addAlphaModulateFixedEffect(50);

好的,我尝试了这条语句,并且实现了想要的功能,只是当时在API无法通过我的需要找到合适的方法

@lvyoufang

共享的示例代码是否已满足您的目的,我们可能会关闭线程?