Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.
« »

Matching the image size with a text frame size

Blogged by Björn Meyer on September 20, 2007 and tagged with Samples.

I just noticed an interesting support request in our support department. The user's intention was to insert an image into a text frame and to readjust the horizontal image size in the case that the text frame is resized.

The Image.Size property is read-only and contains the original size of the image. Images can be scaled using the HorizontalScaling and VerticalScaling properties. The scaling factor can be adjusted in percent. To calculate the proportion between the original size and the new size of the text frame, we simply divide the new frame size by original image size.

private void adaptImageSize(TXTextControl.TextFrame Frame, TXTextControl.Image Image, Size NewSize)
{
Frame.Size = NewSize;
float zoomX = ((float)Frame.Size.Width / (float)Image.Size.Width);
Image.HorizontalScaling = (int)(zoomX * 100f);
}
« Prev:ASP.NET: Getting the client's .NET version
» Next:Centralize Your Documents

top

Top 10 Bestselling Product Award 2007Top 25 Publisher Product Award 2007Top 10 Bestselling Product Award 2007 in JapanTop 25 Bestselling Product Award 2006Top 25 Bestselling Publisher Award 2006Reader's Choice Award, dot.net magazin, 3rd place