string_FontName=Request["fontname"].ToString(); int_FontSize=Convert.ToInt16(Request["fontsize"]); string_ShowName=Request["str"].ToString();
BitmapobjBitmap=null; Graphicsg=null;
FontstringFont=newFont(_FontName,_FontSize,FontStyle.Bold); StringFormatstringFormat=newStringFormat(); stringFormat.FormatFlags=StringFormatFlags.NoWrap;
try { objBitmap=newBitmap(1,1); g=Graphics.FromImage(objBitmap); SizeFstringSize=g.MeasureString(_ShowName,stringFont); intnWidth=(int)stringSize.Width; intnHeight=(int)stringSize.Height; g.Dispose(); objBitmap.Dispose();
objBitmap=newBitmap(nWidth,nHeight); g=Graphics.FromImage(objBitmap); g.FillRectangle(newSolidBrush(Color.Yellow),newRectangle(0,0,nWidth,nHeight)); g.TextRenderingHint=TextRenderingHint.AntiAlias; g.DrawString(_ShowName,stringFont,newSolidBrush(Color.Black),newPointF(0,0),stringFormat); objBitmap.Save(Response.OutputStream,ImageFormat.Gif); } catch(Exceptionee) { Response.Write(ee.ToString()); } finally { if(null!=g)g.Dispose(); if(null!=objBitmap)objBitmap.Dispose(); Response.End(); }
|