Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Thu Mar 03, 2016 7:13 am

I'm creating a large presentation with a lot of images. A few of them need to be resized after the presentation is created but I want to make sure the aspect ratio for the images are protected. The code part I use to put the image in is:

System.Drawing.Image pc_img = System.Drawing.Image.FromFile(pc_img_filename);
RectangleF pc_rect = new RectangleF(66, 313, pc_img.Width, pc_img.Height);
ppt_user.Slides[j].Shapes.AppendEmbedImage(ShapeType.Rectangle, pc_img_Filename, pc_Rect);

Is there a way to lock the aspect ratio for an AppendEmbedImage call?

Thanks
Allan

aneale42@gmail.com
 
Posts: 2
Joined: Wed Mar 02, 2016 6:23 pm

Thu Mar 03, 2016 7:52 am

Hi,

Thanks for you posting.
Please try image.ShapeLocking.AspectRatioProtection = true.
Code: Select all
 
IEmbedImage image = ppt_user.Slides[j].Shapes.AppendEmbedImage(ShapeType.Rectangle, pc_img_Filename, pc_Rect);
 image.ShapeLocking.AspectRatioProtection = true;


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Thu Mar 03, 2016 8:14 pm

Thank you, worked perfectly!

aneale42@gmail.com
 
Posts: 2
Joined: Wed Mar 02, 2016 6:23 pm

Fri Mar 04, 2016 1:44 am

Hi,

Thanks for your feedback.
Welcome to write to us again if you have further problems.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Presentation

cron