public static string GetShapeAsImageURL <T>(T shape, TemplateContext <T> model) { if (!(shape is Shape)) { throw new InvalidOperationException("Object of Shape class expected"); } if (model.Global.Get <bool>("embedImages")) { using (MemoryStream ms = new MemoryStream()) { Bitmap image = (shape as Shape).GetThumbnail(); image.Save(ms, ImageFormat.Png); return("'data:image/png;base64, " + Convert.ToBase64String(ms.ToArray()) + "'"); } } else { var imgSrcPath = model.Output.GetResourcePath(shape); var slidesPath = model.Global.Get <string>("slidesPath"); string result = ShapeHelper.ConvertPathToRelative(imgSrcPath, slidesPath); return(result); } }
public static string GetVideoURL <T>(VideoFrame videoFrame, TemplateContext <T> model) { if (videoFrame == null) { throw new InvalidOperationException("Parameter videoFrame can't be null"); } var videoSrcPath = model.Output.GetResourcePath(videoFrame.EmbeddedVideo); var slidesPath = model.Global.Get <string>("slidesPath"); string result = ShapeHelper.ConvertPathToRelative(videoSrcPath, slidesPath); return(result); }
public static string GetImageURL <T>(IPPImage image, TemplateContext <T> model) { string result = ""; if (!model.Global.Get <bool>("embedImages")) { var imgSrcPath = model.Output.GetResourcePath(image); var slidesPath = model.Global.Get <string>("slidesPath"); result = ShapeHelper.ConvertPathToRelative(imgSrcPath, slidesPath); } else { result = "data:image/png;base64, " + Convert.ToBase64String(image.BinaryData); } return(result); }