Private Function GenerateVCodeImage() Dim oBitmap As Drawing.Bitmap = New Drawing.Bitmap(90, 35) Dim oGraphic As Drawing.Graphics = Drawing.Graphics.FromImage(oBitmap) Dim foreColor As System.Drawing.Color Dim backColor As System.Drawing.Color Dim sText As String = generateVCode(6) Dim sFont As String = "Comic Sans MS" foreColor = System.Drawing.Color.FromArgb(220, 220, 220) backColor = System.Drawing.Color.FromArgb(190, 190, 190) Dim oBrush As New Drawing.Drawing2D.HatchBrush(CType(generateHatchStyle(), Drawing.Drawing2D.HatchStyle), foreColor, backColor) Dim oBrushWrite As New Drawing.SolidBrush(Drawing.Color.Red) oGraphic.FillRectangle(oBrush, 0, 0, 100, 50) oGraphic.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias Dim oFont As New Drawing.Font(sFont, 14) Dim oPoint As New Drawing.PointF(5.0F, 4.0F) oGraphic.DrawString(sText, oFont, oBrushWrite, oPoint) Response.ContentType = "image/jpeg" oBitmap.Save(Response.OutputStream, Drawing.Imaging.ImageFormat.Jpeg) oBitmap.Dispose() Return sText End Function
|