GdPicture.NET Reference Guide
GetTextWidth Method (GdPictureImaging)
Example 





GdPicture14 Namespace > GdPictureImaging Class : GetTextWidth Method
GdPicture Image Identifier.
Text to draw.
The name of the font. IE: "Arial".
The font size in units specified by the FontSetUnit() method.
A member of the FontStyle enumeration.
Calculate the width of the specified text, based on the specified font, font size and font style. The result is measured in units specified by the FontSetUnit() method.
Syntax
'Declaration
 
Public Function GetTextWidth( _
   ByVal ImageID As Integer, _
   ByVal Text As String, _
   ByVal FontName As String, _
   ByVal FontSize As Single, _
   ByVal FontStyle As FontStyle _
) As Single
public function GetTextWidth( 
    ImageID: Integer;
    Text: String;
    FontName: String;
    FontSize: Single;
    FontStyle: FontStyle
): Single; 
public function GetTextWidth( 
   ImageID : int,
   Text : String,
   FontName : String,
   FontSize : float,
   FontStyle : FontStyle
) : float;

Parameters

ImageID
GdPicture Image Identifier.
Text
Text to draw.
FontName
The name of the font. IE: "Arial".
FontSize
The font size in units specified by the FontSetUnit() method.
FontStyle
A member of the FontStyle enumeration.

Return Value

The width of the text measured in units specified by the FontSetUnit() method.
Example
Retrieving the minimal width required to write a certain text on an image.
Dim oGdPictureImaging As New GdPictureImaging
Dim ImageID As Integer
Dim Width As Integer
ImageID = oGdPictureImaging.CreateGdPictureImageFromFile("")
Width = oGdPictureImaging.GetTextWidth(ImageID,  "GdPicture Imaging", "Arial",10.0, FontStyle.FontStyleRegular)
oGdPictureImaging.SaveAsPNG(ImageID, "output.png")
oGdPictureImaging.ReleaseGdPictureImage(ImageID)
See Also

Reference

GdPictureImaging Class
GdPictureImaging Members
FontSetUnit Method
FontGetUnit Method