En C#
//CREAMOS EL
OBJETO IMAGEN
Bitmap
objBmp = new Bitmap(1,
1);
int
Width = 0;
int
Height = 0;
//LE DAMOS
EL FORMATO DE LA FUENTE
Font
objFont = new Font("Arial", 20, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
Graphics
objGraphics = Graphics.FromImage(objBmp);
Width = (int)objGraphics.MeasureString(textBox1.Text,
objFont).Width;
Height = (int)objGraphics.MeasureString(textBox1.Text,
objFont).Height;
objBmp = new
Bitmap(objBmp, new
Size(Width, Height));
objGraphics = Graphics.FromImage(objBmp);
objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
objGraphics.CompositingQuality =
System.Drawing.Drawing2D.CompositingQuality.HighQuality;
objGraphics.InterpolationMode =
System.Drawing.Drawing2D.InterpolationMode.High;
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
objGraphics.DrawString(textBox1.Text,
objFont, new SolidBrush(Color.FromArgb(102, 102, 102)), 0, 0);
objGraphics.Flush();
pictureBox1.Image = objBmp;
En VB.NET
'CREAMOS EL
OBJETO IMAGEN
Dim
objBmp As New Bitmap(1, 1)
Dim Width
As Integer = 0
Dim
Height As Integer
= 0
'LE DAMOS EL
FORMATO DE LA FUENTE
Dim
objFont As New Font("Arial",
20, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Pixel)
Dim
objGraphics As Graphics
= Graphics.FromImage(objBmp)
Width = CInt(objGraphics.MeasureString(textBox1.Text,
objFont).Width)
Height = CInt(objGraphics.MeasureString(textBox1.Text,
objFont).Height)
objBmp = New
Bitmap(objBmp, New
Size(Width, Height))
objGraphics = Graphics.FromImage(objBmp)
objGraphics.SmoothingMode = SmoothingMode.AntiAlias
objGraphics.CompositingQuality =
System.Drawing.Drawing2D.CompositingQuality.HighQuality
objGraphics.InterpolationMode =
System.Drawing.Drawing2D.InterpolationMode.High
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias
objGraphics.DrawString(textBox1.Text,
objFont, New SolidBrush(Color.FromArgb(102, 102, 102)), 0, 0)
objGraphics.Flush()
pictureBox1.Image = objBmp
Descargar ejemplo ConvertirTextoImagen.rar