Adding Picture Frame with Animation

Adding Picture Frames with Animation

The code samples below create a presentation with a slide, add an image with a picture frame and applies animation to it.

VSTO 2008 Example

Using VSTO 2008, take the following steps:

  1. Create a presentation.
  2. Add an empty slide.
  3. Add a picture shape to the slide.
  4. Apply animation to the picture.
  5. Write the presentation to disk.

The output presentation, created with VSTO

todo:image_alt_text

//Creating empty presentation
PowerPoint.Presentation pres = Globals.ThisAddIn.Application.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoFalse);

//Add a blank slide
PowerPoint.Slide sld = pres.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutBlank);

//Add Picture Frame
PowerPoint.Shape PicFrame = sld.Shapes.AddPicture(@"D:\Aspose Data\Desert.jpg",
Microsoft.Office.Core.MsoTriState.msoTriStateMixed,
Microsoft.Office.Core.MsoTriState.msoTriStateMixed, 150, 100, 400, 300);

//Applying animation on picture frame
PicFrame.AnimationSettings.EntryEffect = Microsoft.Office.Interop.PowerPoint.PpEntryEffect.ppEffectBoxIn;

//Saving Presentation
pres.SaveAs("d:\\ VSTOAnim.ppt", PowerPoint.PpSaveAsFileType.ppSaveAsPresentation,
Microsoft.Office.Core.MsoTriState.msoFalse);

Aspose.Slides for .NET Example

Using Aspose.Slides for .NET, perform the following steps:

  1. Create a presentation.
  2. Access the first slide.
  3. Add an image to a picture collection.
  4. Add a picture shape to the slide.
  5. Apply animation to the picture.
  6. Write the presentation to disk.

The output presentation, created with Aspose.Slides

todo:image_alt_text

//Creating empty presentation
Presentation pres = new Presentation();

//Accessing the First slide
ISlide slide = pres.Slides[0];

//Adding the picture object to pictures collection of the presentation
System.Drawing.Image pic = (System.Drawing.Image)new Bitmap("C:\\Data\\aspose.jpg");

IPPImage imgx = pres.Images.AddImage(pic);

//Add Picture Frame with height and width equivalent of Picture
IPictureFrame PicFrame = slide.Shapes.AddPictureFrame(ShapeType.Rectangle, 50, 150, imgx.Width, imgx.Height, imgx);

//Applying animation on picture frame
//PicFrame.AnimationSettings.EntryEffect = ShapeEntryEffect.BoxIn;

//Saving Presentation
pres.Save("c:\\data\\AsposeAnim.ppt", SaveFormat.Ppt);