C # generation verification code

xiaoxiao2021-03-06  25

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;

转载请注明原文地址:https://www.9cbs.com/read-65490.html

New Post(0)