C # generation verification code

xiaoxiao2021-03-06  26

public static bool GenRad (string strRadnum, System.IO.Stream oOutStream, int nWidth, int nHeight) {System.Drawing.Bitmap oImage; try {oImage = new System.Drawing.Bitmap (nWidth, nHeight);} catch (System. Exception Dr_ERr) {CardSale.Tools.ErrorLog.WriteLog ( "Photo / GenRad (string strRadnum, System.IO.Stream oOutStream, int nWidth, int nHeight)", Dr_ERr.Message); return false;} System.Drawing.Graphics oGr = System.Drawing .Graphics.FromImage (oImage); System.Drawing.SolidBrush oBack = new System.Drawing.SolidBrush (System.Drawing.Color.FromArgb (255,255,255)); oGr.FillRectangle (oBack, 0,0, nWidth, nHeight); System.Drawing.Pen oPen = new System.Drawing.Pen (System.Drawing.Color.Black); System.Drawing.Font oFont = new System.Drawing.Font (System.Drawing.FontFamily.GenericSansSerif, 12) ; System.Drawing.SolidBrush oLine = new System.Drawing.SolidBrush (System.Drawing.Color.FromArgb (0,0,0)); System.Drawing.Imaging.ImageAttributes imageAttr = new System.Drawing.Imaging .ImageAttributes (); imageAttr.SetGamma (0.1F); oGr.DrawString (strRadnum, oFont, oLine, 5,0); try {oImage.Save (oOutStream, System.Drawing.Imaging.ImageFormat.Jpeg);} catch { OGR.Dispose (); oomage.dispose ();} OGR.Dispose (); OIMAGE.DISPOSE (); Return true;

The key is the design in the web page. If the design is incorrect, some users may not enter the verification code correctly, which may not change the user's verification code than if the user is 3721.

Reference method: Please