Bringing Internet Technology Innovations to Market since 1991
  News Products Outsourcing About Us Contact Us
what's new?what's new? featuresfeatures samplessamples manualmanual downloaddownload buybuy
  Tonec Homepage
ProductsActive Imagesamples

Please view complete list of samples

Sample 19

Get dimensions of a text string

The sample shows how to get the width and the height of a text string. It finds the smallest rectangle that the text string can be inscribed into.


Dim im1
Dim rect
'Create Object
Set im1 = CreateObject("ActiveImage.Images.1")

'Set path to true type fonts
'Set font size
im1.SetFontSizeTTF 36
'Set Font Name
im1.SetFontTTF "ariblk"

'Create empty canvass
im1.CreateImage 400, 200

im1.SetAlphaColor 0,0,0,0
im1.Fill 1,1

'Set Color
im1.SetAlphaColor 128, 0, 192,0

'Get rectangle
rect = im1.GetTextTTFRectangle(50, 80 , "TONEC.COM")

'Draw a text with selected font
im1.DrawTextTTF 50, 80 , "TONEC.COM"

im1.SetAlphaColor 255, 0, 0,0
im1.DrawRectangle rect(0)-1,rect(1)-1,rect(2),rect(3)

'Save image to a file
im1.WriteToFile "C:\AI\GetTTFRect.png"
im1.SetImageType 4
im1.WriteToFile "C:\AI\GetTTFRect.bmp"
im1.SetImageType 1
im1.WriteToFile "C:\AI\GetTTFRect.jpg"
im1.SetImageType 3
im1.WriteToFile "C:\AI\GetTTFRect.gif"

Set im1 = Nothing

 Picture 1. GetTTFRect.gif (size - 10,5 Kb)

Next sample >> 

If you have any questions or bug reports, write to for technical support.

  TonecPrivacy Policy
  1999-2005. Tonec, Inc. All rights reserved.