Spire.Presentation支持给PowerPoint文档中的图片设置效果,例如发光、阴影、映像和柔化边缘等。本文将介绍如何使用Spire.Presentation给图片设置发光和阴影效果。
C#
//创建Presentation实例
Presentation ppt = new Presentation();
//加载PowerPoint文档
ppt.LoadFromFile("Input.pptx");
//获取第一张幻灯片
ISlide slide = ppt.Slides[0];
//获取第一张图片
SlidePicture pic1 = slide.Shapes[0] as SlidePicture;
//给图片设置发光效果
GlowEffect glowEffect = new GlowEffect();
glowEffect.ColorFormat.Color = Color.Yellow;
glowEffect.ColorFormat.Saturation = 1f;
glowEffect.Radius = 10;
pic1.EffectDag.GlowEffect = glowEffect;
//获取第二张图片
SlidePicture pic2 = slide.Shapes[1] as SlidePicture;
//给图片设置阴影效果
OuterShadowEffect shadow = new OuterShadowEffect();
shadow.ColorFormat.Color = Color.Gray;
shadow.Distance = 8;
shadow.BlurRadius = 10;
pic2.EffectDag.OuterShadowEffect = shadow;
//保存文档
ppt.SaveToFile("Output.pptx", FileFormat.Pptx2013);
VB.NET
'创建Presentation实例
Dim ppt As New Presentation()
'加载PowerPoint文档
ppt.LoadFromFile("Input.pptx")
'获取第一张幻灯片
Dim slide As ISlide = ppt.Slides(0)
'获取第一张图片
Dim pic1 As SlidePicture = TryCast(slide.Shapes(0), SlidePicture)
'给图片设置发光效果
Dim glowEffect As New GlowEffect()
glowEffect.ColorFormat.Color = Color.Yellow
glowEffect.ColorFormat.Saturation = 1F
glowEffect.Radius = 10
pic1.EffectDag.GlowEffect = glowEffect
'获取第二张图片
Dim pic2 As SlidePicture = TryCast(slide.Shapes(1), SlidePicture)
'给图片设置阴影效果
Dim shadow As New OuterShadowEffect()
shadow.ColorFormat.Color = Color.Gray
shadow.Distance = 8
shadow.BlurRadius = 10
pic2.EffectDag.OuterShadowEffect = shadow
'保存文档
ppt.SaveToFile("Output.pptx", FileFormat.Pptx2013)
效果图: