passing in a byte[] named as image
add this above
// Insert the new slide into the slide list after the previous slide.
SlideId newSlideId = slideIdList.InsertAfter(new SlideId(), prevSlideId);
if (image!=null)
{
var part = slidePart.AddImagePart(ImagePartType.Png);
part.FeedData(new MemoryStream(image));
var tree = slidePart.Slide.Descendants<P.ShapeTree>().First();
var picture = new P.Picture();
picture.NonVisualPictureProperties = new P.NonVisualPictureProperties();
picture.NonVisualPictureProperties.Append(new P.NonVisualDrawingProperties
{
Name = "My Shape",
Id = (UInt32)tree.ChildElements.Count - 1
});
var nonVisualPictureDrawingProperties = new P.NonVisualPictureDrawingProperties();
nonVisualPictureDrawingProperties.Append(new D.PictureLocks()
{
NoChangeAspect = true
});
picture.NonVisualPictureProperties.Append(nonVisualPictureDrawingProperties);
picture.NonVisualPictureProperties.Append(new P.ApplicationNonVisualDrawingProperties());
var blipFill = new P.BlipFill();
var blip1 = new D.Blip()
{
Embed = slidePart.GetIdOfPart(part)
};
var blipExtensionList1 = new D.BlipExtensionList();
var blipExtension1 = new D.BlipExtension()
{
Uri = "{28A0092B-C50C-407E-A947-70E740481C1C}"
};
var useLocalDpi1 = new DocumentFormat.OpenXml.Office2010.Drawing.UseLocalDpi()
{
Val = false
};
useLocalDpi1.AddNamespaceDeclaration("a14", "http://schemas.microsoft.com/office/drawing/2010/main");
blipExtension1.Append(useLocalDpi1);
blipExtensionList1.Append(blipExtension1);
blip1.Append(blipExtensionList1);
var stretch = new D.Stretch();
stretch.Append(new D.FillRectangle());
blipFill.Append(blip1);
blipFill.Append(stretch);
picture.Append(blipFill);
picture.ShapeProperties = new P.ShapeProperties();
picture.ShapeProperties.Transform2D = new D.Transform2D();
picture.ShapeProperties.Transform2D.Append(new D.Offset
{
X = 2500000,
Y = 2500000,
});
picture.ShapeProperties.Transform2D.Append(new D.Extents
{
Cx = 5000000,
Cy = 5000000,
});
picture.ShapeProperties.Append(new D.PresetGeometry
{
Preset = D.ShapeTypeValues.Rectangle
});
tree.Append(picture);
}
this was taken and amended from
here using "Md. Zakir Hossain" code..