GetTextDimensions
The GetTextDimensions obtains size of bounding rectangle of the text string, using the currently created font.
GetTextDimensions
sText, iWidth, iHeight [,bUnicode]
Parameters
-
sText
-
String to get information about.
-
iWidth
- On return this parameter contains the width of text bounding rectangle in pixels.
-
iHeight
- On return this parameter contains the height of text bounding rectangle in pixels.
-
bUnicode
- Optional. If True the function will use the Unicode representation
of the string. If False the function will use the ASCII representaion.
The default value is False.
Remarks
Use this function to make graphic positioning in your images more accurate.
Example
The example shows how to place the text string exactly in the center of the image.
View result
<%
Set g=CreateObject("shotgraph.image")
xsize=320
ysize=240
g.CreateImage xsize,ysize,8
g.SetColor 0,204,204,255
g.SetColor 1,0,0,0
g.SetBgColor 0
g.FillRect 0,0,xsize,ysize
g.SetTextColor 1
g.CreateFont "Arial",0,45,0,True,False,False,False
text="CENTERED"
g.GetTextDimensions text,x,y
g.SetBkMode "TRANSPARENT"
g.SetTextAlign "TA_LEFT","TA_TOP"
g.TextOut xsize/2-x/2,ysize/2-y/2,text
g.BuildPalette 0
Response.BinaryWrite g.GifImage(-1,1,"")
%>