إضافة إطار صورة مع حركة في VSTO و Aspose.Slides

إن عينات الشيفرة أدناه تنشئ عرضًا تقديميًا يحتوي على شريحة، وتضيف صورةً بإطار وتطبق حركةً عليها.

VSTO

باستخدام VSTO، اتبع الخطوات التالية:

  1. إنشاء عرض تقديمي.
  2. إضافة شريحة فارغة.
  3. إضافة شكل صورة إلى الشريحة.
  4. تطبيق حركة على الصورة.
  5. حفظ العرض التقديمي إلى القرص.

 //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("pic.jpeg",

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("VSTOAnim.ppt", PowerPoint.PpSaveAsFileType.ppSaveAsPresentation,

Microsoft.Office.Core.MsoTriState.msoFalse);

Aspose.Slides

باستخدام Aspose.Slides لـ .NET، قم بتنفيذ الخطوات التالية:

  1. إنشاء عرض تقديمي.
  2. الوصول إلى الشريحة الأولى.
  3. إضافة صورة إلى مجموعة الصور.
  4. إضافة شكل صورة إلى الشريحة.
  5. تطبيق حركة على الصورة.
  6. حفظ العرض التقديمي إلى القرص.

 //Creating empty presentation

Presentation pres = new Presentation();

//Accessing the First slide

Slide slide = pres.GetSlideByPosition(1);

//Adding the picture object to pictures collection of the presentation

Picture pic = new Picture(pres, "pic.jpeg");

//After the picture object is added, the picture is given a uniqe picture Id

int picId = pres.Pictures.Add(pic);

//Adding Picture Frame

Shape PicFrame = slide.Shapes.AddPictureFrame(picId, 1450, 1100, 2500, 2200);

//Applying animation on picture frame

PicFrame.AnimationSettings.EntryEffect = ShapeEntryEffect.BoxIn;

//Saving Presentation

pres.Write("AsposeAnim.ppt");

Download Sample Code