إضافة إطار صورة إلى العرض التقديمي
Contents
[
Hide
]
VSTO
فيما يلي الكود لإضافة صورة في عرض تقديمي باستخدام VSTO:
string ImageFilePath="AddPicture.jpg";
Slide slide = Application.ActivePresentation.Slides[1];
slide.Shapes.AddPicture(ImageFilePath, Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoCTrue, 0, 0);
Aspose.Slides
لإضافة إطار صورة بسيط إلى الشريحة الخاصة بك، يرجى اتباع الخطوات أدناه:
- إنشاء مثيل لفئة Presentation.
- الحصول على مرجع الشريحة باستخدام فهرستها.
- إنشاء كائن Image عن طريق إضافة صورة إلى مجموعة Images المرتبطة بكائن Presentation الذي سيُستخدم لملء الشكل.
- حساب عرض وارتفاع الصورة.
- إنشاء PictureFrame وفقًا للعرض والارتفاع باستخدام الطريقة AddPictureFrame التي يوفرها كائن Shapes المرتبط بالشريحة المرجعية.
- إضافة إطار صورة (يحتوي على الصورة) إلى الشريحة.
- كتابة العرض التقديمي المعدل كملف PPTX.
يتم تنفيذ الخطوات السابقة في المثال المعطى أدناه.
string ImageFilePath = "AddPicture.jpg";
//Instantiate Prseetation class that represents the PPTX
Presentation pres = new Presentation();
//Get the first slide
ISlide sld = pres.Slides[0];
//Instantiate the ImageEx class
using IImage img = Images.FromFile(ImageFilePath);
IPPImage imgx = pres.Images.AddImage(img);
//Add Picture Frame with height and width equivalent of Picture
sld.Shapes.AddPictureFrame(ShapeType.Rectangle, 50, 150, imgx.Width, imgx.Height, imgx);