Hi guys.
I need to align on center picture which I add into slide,
how to do that?
Here is my code:
private void AddPicture(SlideEx slide, MemoryStream ChartStream, float coordinateX, float coordinateY)
{
if (ChartStream == null)
{
return;
}
System.Drawing.Image img = (System.Drawing.Image)new Bitmap(ChartStream);
ImageEx imgx = presentation.Images.AddImage(img);
slide.Shapes.AddPictureFrame(ShapeTypeEx.Rectangle, coordinateX, coordinateY, (Convert.ToInt32(imgx.Width * 0.67)), (Convert.ToInt32(imgx.Height*0.67)), imgx);
}
Thanks.
Hi,
Hi Mudassir,
I provided a single and very simple method.
I don’t know if I can add some additional info regarding my issue.
Hi,
Hi,
I’m attaching zip files.
1) SlideReport_ImageAlignment.pptx - actually slide report. (small part of it)
2) On the files Centered_Image.jpg and Centered_2_Images.jpg you’ll find how I’d like to make images centered.
3) And of course instead of creating images in slide report from Stream object,
like in my source code:
System.Drawing.Image img = (System.Drawing.Image)new Bitmap(ChartStream);
ImageEx imgx = presentation.Images.AddImage(img);
you may load prepared images:
Chart.png
Chart2.png
Chart3.png
Thanks
Hi,
public static void addPicFrame(){//Instantiate PrseetationEx class that represents the PPTXPresentationEx pres = new PresentationEx();//Get the first slideSlideEx sld = pres.Slides[0];float centerX = pres.SlideSize.Size.Width/2;float centerY = pres.SlideSize.Size.Height/2;//Instantiate the ImageEx classSystem.Drawing.Image img = (System.Drawing.Image)new Bitmap(“d:\Aspose Data\Penguins.jpg”);ImageEx imgx = pres.Images.AddImage(img);float imagePosX = centerX - (imgx.Width/2);float imagePosY = centerY - (imgx.Height/2);//Add Picture Frame with height and width equivalent of Pictureint id = sld.Shapes.AddPictureFrame(ShapeTypeEx.Rectangle, imagePosX, imagePosY, imgx.Width , imgx.Height, imgx);PictureFrameEx picfram = (PictureFrameEx)sld.Shapes[id];//Write the PPTX file to diskpres.Write(“d:\Aspose Data\RectPicFrame.pptx”);}