string _FontName = Request["nomedafonte"].ToString();
int _FontSize = Convert.ToInt16(Request["tamanho da fonte"]);
string _ShowName = Solicitação["str"].ToString();
Bitmap objBitmap = null;
Gráficos g = nulo;
Fonte stringFont = new Font(_FontName, _FontSize, FontStyle.Bold );
StringFormat stringFormat = new StringFormat();
stringFormat.FormatFlags = StringFormatFlags.NoWrap;
tentar
{
objBitmap = novo Bitmap(1,1);
g = Graphics.FromImage(objBitmap);
TamanhoF stringSize = g.MeasureString(_ShowName, stringFont);
int nLargura = (int)stringSize.Width;
int nHeight = (int)stringSize.Height;
g.Dispose();
objBitmap.Dispose();
objBitmap = novo Bitmap(nLargura,nAltura);
g = Graphics.FromImage(objBitmap);
g.FillRectangle(novo SolidBrush(Color.Yellow), novo Rectangle(0,0,nWidth,nHeight));
g.TextRenderingHint = TextRenderingHint.AntiAlias;
g.DrawString(_ShowName, stringFont, novo SolidBrush(Color.Black), novo PointF(0, 0), stringFormat);
objBitmap.Save(Response.OutputStream, ImageFormat.Gif);
}
pegar (Exceção ee)
{
Response.Write(ee.ToString());
}
finalmente
{
if (nulo! = g) g.Dispose();
if (nulo! = objBitmap) objBitmap.Dispose();
Response.End();
}