On the attached picture you may find image, inserted in slide.
Scale - height and width is always set to 133 %.
How programmatically (C#) I can set scale to 100% ?
Thanks in advance.
I’m attaching slide (just in case)
Hi Alex,
I have observed that you have made the similar inquiry in past as well over this link:
https://forum.aspose.com/t/picture-scale-size-in-the-slide/72287
Can you please share the source image with us that you are trying to embed in your presentation so that I may be able to carry my investigation further. For normal image on my side, I am not getting the issue shared by you.
Many Thanks,
Hi Mudassir,
I attached power-point with image as you requested.
Method which builds slide with image:
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, imgx.Width, imgx.Height, imgx);
}
So, I’m not using File (image) to put in slide, I’m using MemoryStream object.
In my similar request (about which I forgot that have created), you said that possible reason could be that size of picture frame is bigger than image size. But I don’t know how to change picture frame size.
Hi Alex,
public static void addPicFrame(){//Instantiate PrseetationEx class that represents the PPTXPresentationEx pres = new PresentationEx();//Get the first slideSlideEx sld = pres.Slides[0];//Instantiate the ImageEx classSystem.Drawing.Image img = (System.Drawing.Image)new Bitmap(“d:\Aspose Data\Picture1.png”);ImageEx imgx = pres.Images.AddImage(img);//Add Picture Frame with height and width equivalent of Pictureint id=sld.Shapes.AddPictureFrame(ShapeTypeEx.Rectangle, 50, 50, imgx.Width, imgx.Height, imgx);//Write the PPTX file to diskpres.Write(“d:\Aspose Data\RectPicFrame.pptx”);}
Hi Mudassir
Please use attached file for reproducting my case.
That file is serialized MemoryStream object (I prepared it from my application speccially for this my request)
You may deserialize it like that:
MemoryStream ms = new MemoryStream();
FileStream file = new FileStream("MemoryStream.bin", FileMode.Open, FileAccess.Read);
byte[] bytes = new byte[file.Length];
file.Read(bytes, 0, (int)file.Length);
ms.Write(bytes, 0, (int)file.Length);
file.Close();
ms.Close();
Thanks
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;String imagePath=@"D:\Aspose Data\MemoryStream\";MemoryStream ms = new MemoryStream();FileStream file = new FileStream(imagePath+"MemoryStream.bin", FileMode.Open, FileAccess.Read);byte[] bytes = new byte[file.Length];file.Read(bytes, 0, (int)file.Length);ms.Write(bytes, 0, (int)file.Length);file.Close();ms.Position = 0;System.Drawing.Image img = (System.Drawing.Image)new Bitmap(ms);ms.Close();//Instantiate the ImageEx class// System.Drawing.Image img = (System.Drawing.Image)new Bitmap("d:\\Aspose Data\\Picture1.png");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, 50, 50, imgx.Width, imgx.Height, imgx);PictureFrameEx picfram = (PictureFrameEx)sld.Shapes[id];//Write the PPTX file to diskpres.Write("d:\\Aspose Data\\RectPicFrame.pptx");}
I have the same problem with the following base64 encoded image:
var lImage = Convert.FromBase64String(base64);<span style="color:green;">// Get memory stream to image.</span> <span style="color:blue;">var</span> ms = <span style="color:blue;">new</span> <span style="color:#2b91af;">MemoryStream</span>(lImage); <span style="color:green;">// We don't dispose this stream because of the remarks here : http://msdn.microsoft.com/en-us/library/93z9ee4x.aspx (ImageEx seems to cerate an Image object too)</span>
ImageEx imgx = lPres.Images.AddImage(ms);
Hi Kostas,
I like to share that an issue with ID SLIDESNET-34419 has been created as new feature request to provide the image scaling options for picture frame or other shapes in Aspose.Slides as given in very first post of this slide. Once the properties will be available they can be used to set the image width or height in percentages w.r.t actual image width or height.
Many Thanks,
Hi Alex,
I like to share that we have introduced the support for setting the RelativeScaleHeight and RelativeScaleWidth in Aspose.Slides for .NET 7.9.0. Please try using the following sample code on your end to serve the purpose.
PresentationEx pres = new PresentationEx(Path.Combine(“34419.pptx”));
PictureFrameEx pf = pres.Slides[0].Shapes[0] as PictureFrameEx;
pf.RelativeScaleHeight = 0.8f;
pf.RelativeScaleWidth = 1.35f;
pres.Write(“34419 out.pptx”);
I will share the product notification with you shortly.
Many Thanks,
The issues you have found earlier (filed as SLIDESNET-34419) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
Thanks for notification.