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)
效果图: