IImageData image = ppt.Images.Append(Image.FromFile("test.jpg"));
if (shape is GroupShape groupShape)
{
groupShape.Fill.PictureFill.Picture.EmbedImage = image;
}
GroupShape groupShape = shape as GroupShape;
// 取消组合
sourceSlide.Ungroup(groupShape);
// 获取到要删除的shape对象及其位置
IShape replacedShape = groupShape.Shapes[1];
RectangleF rectangle = replacedShape.Frame.Rectangle;
// 删除该图形
sourceSlide.Shapes.Remove(replacedShape);
// 在已删除的shape处重新添加一个图形,例如矩形
sourceSlide.Shapes.AppendShape(ShapeType.Rectangle, rectangle);