Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Sun Jan 10, 2021 12:39 pm

How can I get the transparency value of the shape?

Image

estry2020
 
Posts: 2
Joined: Sun Dec 20, 2020 6:25 pm

Mon Jan 11, 2021 5:38 am

Hello,

Thanks for your inquiry and sorry for the late reply as weekend.
Please refer to the following code to get the transparency value of a shape. If there are any questions, just feel free to contact us.
Code: Select all
            Presentation ppt = new Presentation();
            ppt.LoadFromFile("transparency.pptx");
            ShapeCollection shapes = ppt.Slides[0].Shapes;
            foreach (Shape shape in shapes)
            {
                shape.Fill.FillType = FillFormatType.Solid;
                Color color = shape.Fill.SolidColor.Color;
                double a = color.A;
                double transparency= Math.Round((255 - a)/ 255,2);
            }
            string result = "SetImageTransparency.pptx";
            ppt.SaveToFile(result, FileFormat.Pptx2013);


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Wed Jan 20, 2021 9:35 am

Hello,

Can the code I provided solve your problem? Could you please give us some feedback at your convenience?

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Wed Feb 03, 2021 12:02 pm

Thanks for your help! I solved the problem like this:
int transparency = (shape as IShape).Fill.SolidColor.Color.A;

estry2020
 
Posts: 2
Joined: Sun Dec 20, 2020 6:25 pm

Thu Feb 04, 2021 1:30 am

Hello,

Thanks for your response.
I am glad to hear that. If you encounter any issues related to our products in the future, just feel free to contact us.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.Presentation