GdPicture14 Namespace
/
GdPictureImaging Class
/
DrawTextBox Method
/ DrawTextBox(Int32,String,Int32,Int32,Int32,Int32,Single,TextAlignment,GdPictureFontStyle,Int32,String,Boolean,Boolean) Method
DrawTextBox(Int32,String,Int32,Int32,Int32,Int32,Single,TextAlignment,GdPictureFontStyle,Int32,String,Boolean,Boolean) Method
In This Topic
Draws an aligned text into a bounding box on a GdPicture image. The drawing color is specified with an integer value.
Syntax
'Declaration
Public Overloads Function DrawTextBox( _
ByVal As Integer, _
ByVal As String, _
ByVal As Integer, _
ByVal As Integer, _
ByVal As Integer, _
ByVal As Integer, _
ByVal As Single, _
ByVal As TextAlignment, _
ByVal As GdPictureFontStyle, _
ByVal As Integer, _
ByVal As String, _
ByVal As Boolean, _
ByVal As Boolean _
) As GdPictureStatus
public GdPictureStatus DrawTextBox(
int ,
string ,
int ,
int ,
int ,
int ,
float ,
TextAlignment ,
GdPictureFontStyle ,
int ,
string ,
bool ,
bool
)
public function DrawTextBox(
: Integer;
: String;
: Integer;
: Integer;
: Integer;
: Integer;
: Single;
: TextAlignment;
: GdPictureFontStyle;
: Integer;
: String;
: Boolean;
: Boolean
): GdPictureStatus;
public function DrawTextBox(
: int,
: String,
: int,
: int,
: int,
: int,
: float,
: TextAlignment,
: GdPictureFontStyle,
: int,
: String,
: boolean,
: boolean
) : GdPictureStatus;
public: GdPictureStatus DrawTextBox(
int ,
string* ,
int ,
int ,
int ,
int ,
float ,
TextAlignment ,
GdPictureFontStyle ,
int ,
string* ,
bool ,
bool
)
public:
GdPictureStatus DrawTextBox(
int ,
String^ ,
int ,
int ,
int ,
int ,
float ,
TextAlignment ,
GdPictureFontStyle ,
int ,
String^ ,
bool ,
bool
)
Parameters
- ImageID
- GdPicture image identifier.
- Text
- Text to draw.
- Left
- Specifies the x-coordinate of the upper-left corner of the text box.
- Top
- Specifies the y-coordinate of the upper-left corner of the text box.
- Width
- Specifies the width, in pixels, of the text box.
- Height
- Specifies the height, in pixels, of the text box.
- FontSize
- The font size in units specified by the FontSetUnit() method.
- Alignment
- A member of the TextAlign enumeration.
- FontStyle
- A member of the FontStyle enumeration.
- TextColor
- Color of the text. A suitable color value can be obtained by using the ARGBI() method.
- FontName
- The name of the font. IE: "Arial".
- DrawBox
- Set this parameter to True to draw the textbox that bounds the text.
- AntiAlias
- Set to True to apply the Antialiasing algorithm else False.
Return Value
A member of the GdPictureStatus enumeration.
Example
Drawing some text on images.
Drawing red text using left aligned text box on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.jpg");
// Draw text in the top left corner of the image.
gdpictureImaging.DrawTextBox(imageID, "This is left aligned text by GdPicture.Net", 5, 5, 250, 150, 24, TextAlignment.TextAlignmentNear, GdPicture14.FontStyle.FontStyleRegular, gdpictureImaging.ARGBI(255, 255, 0, 0), "Arial", true, true);
gdpictureImaging.SaveAsJPEG(imageID, "output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Drawing sample text into a bounding box and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
GdPicture14.FontStyle fontStyle = GdPicture14.FontStyle.FontStyleItalic;
string text = "Long sample text";
int redColor = gdpictureImaging.ARGBI(255, 255, 0, 0);
int fontSize = 12;
// Create background image.
int backImage = gdpictureImaging.CreateNewGdPictureImage(320, 200, 32, gdpictureImaging.ARGBI(255, 255, 255, 255));
// Draw sample text into the background image.
gdpictureImaging.DrawTextBox(backImage, text, 20, 20, 100, 40, fontSize, TextAlignment.TextAlignmentNear, fontStyle, redColor, "Times", true, true);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
Example
Drawing some text on images.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.jpg");
// Draw text in the top left corner of the image.
gdpictureImaging.DrawTextBox(imageID, "This is left aligned text by GdPicture.Net", 5, 5, 250, 150, 24, TextAlignment.TextAlignmentNear, GdPicture14.FontStyle.FontStyleRegular, gdpictureImaging.ARGBI(255, 255, 0, 0), "Arial", true, true);
gdpictureImaging.SaveAsJPEG(imageID, "output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
GdPicture14.FontStyle fontStyle = GdPicture14.FontStyle.FontStyleItalic;
string text = "Long sample text";
int redColor = gdpictureImaging.ARGBI(255, 255, 0, 0);
int fontSize = 12;
// Create background image.
int backImage = gdpictureImaging.CreateNewGdPictureImage(320, 200, 32, gdpictureImaging.ARGBI(255, 255, 255, 255));
// Draw sample text into the background image.
gdpictureImaging.DrawTextBox(backImage, text, 20, 20, 100, 40, fontSize, TextAlignment.TextAlignmentNear, fontStyle, redColor, "Times", true, true);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
See Also