|118598||Mar 23,2015 12:08 PM UTC||Mar 24,2015 05:00 PM UTC||WPF||2|
var range = ws.Range[5, 2]; var pic = ws.Pictures.AddPicture(range.Row, range.Column, @"D:\Pictures\clouds.JPG");int scale = (int)(range.ColumnWidth / pic.Width); pic.Scale(scale, scale);
This results in a scale factor of 0, because as far as I can tell, the scale factors have to be integers and in percents. The use of integers for dimensions throughout the shapes functionality seemed a bit weird, but having integer scale factors is just bizarre.
Just to test it, I tried setting the picture width to the column width.
pic.Width = (int)range.ColumnWidth;
This is completely different when I open up the test file... See the attached image.
I can't say I have been very happy with the functionality for shapes in Excel so far, but if you could help it would be much appreciated :)
Thank you for using Syncfusion products.
Regarding Scale() query:
The Scale method of the IPictureShape is used to resize the image in scale width and scale height which is in percent. The below code snippet describes the implementation inside the Scale().
Width = ( int )( Width * scaleWidth / 100.0 );
Height = ( int )( Height * scaleHeight / 100.0 );
Here, the scaleWidth and scaleHeight should be in percent.
Regarding ColumnWidth/RowHeight query:
As you mentioned, for all the shape related dimensions, you must use the pixel value. The table describes the point and pixel values of the range for RowHeight and ColumnWidth.
Property in Points
Equivalent pixel values
Please let us know if you have any concerns.
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
or the page will be automatically redirected to sign-in page in 10 seconds.