Hi Team,
Aspose Version: 20.1
Language: C#
I am looking to extract the background image applied on PPTX using below options
Add a background picture to slides - PowerPoint (microsoft.com)
Below is the code I am using. It does extract the original image but not the image with effects or styles applied to it. I have applied transparency on the image and want to get an image from Aspose API.
Output → BackImage_Slide_Aspose.Slides.Slide.jpeg (359.6 KB)
PPTX → sample.zip (400.3 KB)
public static System.Drawing.Imaging.ImageFormat GetImageFormat(String ImageType)
{
System.Drawing.Imaging.ImageFormat Format = System.Drawing.Imaging.ImageFormat.Jpeg;
switch (ImageType)
{
case "jpeg":
Format = System.Drawing.Imaging.ImageFormat.Jpeg;
break;
case "emf":
Format = System.Drawing.Imaging.ImageFormat.Emf;
break;
case "bmp":
Format = System.Drawing.Imaging.ImageFormat.Bmp;
break;
case "png":
Format = System.Drawing.Imaging.ImageFormat.Png;
break;
case "wmf":
Format = System.Drawing.Imaging.ImageFormat.Wmf;
break;
case "gif":
Format = System.Drawing.Imaging.ImageFormat.Gif;
break;
}
return Format;
}
Presentation pres = new Presentation(m_szPptxPath);
ISlide sl = pres.Slides[0];
Aspose.Slides.IPPImage img = null;
String ImageType = "";
Aspose.Slides.IPPImage Backimg = null;
System.Drawing.Imaging.ImageFormat Format = System.Drawing.Imaging.ImageFormat.Jpeg;
if (sl.Background.FillFormat.FillType == FillType.Picture)
{
//Getting the back picture
Backimg = sl.Background.FillFormat.PictureFillFormat.Picture.Image;
//Setting the desired picture format
ImageType = Backimg.ContentType;
ImageType = ImageType.Remove(0, ImageType.IndexOf("/") + 1);
Format = GetImageFormat(ImageType);
String ImagePath = "./input/BackImage_";
Backimg.SystemImage.Save(ImagePath + "Slide_" + sl.ToString() + "." + ImageType, ImageFormat.Jpeg);
}
Is there any API for that?
Please share your thoughts.
Thanks
~ Praveen