string _FontName = Permintaan["namafont"].ToString();
int _FontSize = Convert.ToInt16(Permintaan["ukuran font"]);
string _ShowName = Permintaan["str"].ToString();
Bitmap objBitmap = null;
Grafik g = null ;
Font stringFont = Font baru(_FontName, _FontSize, FontStyle.Bold );
StringFormat stringFormat = StringFormat baru();
stringFormat.FormatFlags = StringFormatFlags.NoWrap;
mencoba
{
objBitmap = Bitmap baru(1,1);
g = Grafik.FromImage(objBitmap);
UkuranF stringUkuran = g.MeasureString(_ShowName, stringFont);
int nLebar = (int)ukuran string.Lebar;
int nTinggi = (int)ukuran string.Tinggi;
g.Buang();
objBitmap.Buang();
objBitmap = Bitmap baru(nLebar,nTinggi);
g = Grafik.FromImage(objBitmap);
g.FillRectangle(SolidBrush baru(Warna.Kuning), Persegi Panjang baru(0,0,nLebar,nTinggi));
g.TextRenderingHint = TextRenderingHint.AntiAlias;
g.DrawString(_ShowName, stringFont, SolidBrush baru(Warna.Hitam), PointF baru(0, 0), stringFormat);
objBitmap.Simpan(Respon.OutputStream, ImageFormat.Gif);
}
menangkap (Pengecualian ee)
{
Respon.Write(ee.ToString());
}
Akhirnya
{
jika (null != g) g.Buang();
if (null != objBitmap) objBitmap.Dispose();
Respon.End();
}