public VerifyImageInfo GenerateImage(string code, int width, int height, Color bgcolor) { VerifyImageInfo verifyImageInfo = new VerifyImageInfo("image/pjpeg", ImageFormat.Jpeg); width = 47; height = 20; Bitmap image = new Bitmap(width, height, PixelFormat.Format32bppArgb); Graphics graphics = Graphics.FromImage(image); graphics.SmoothingMode = SmoothingMode.HighSpeed; graphics.Clear(bgcolor); int num = 60; Pen pen = new Pen(Color.FromArgb(VerifyImage.Next(50) + num, VerifyImage.Next(50) + num, VerifyImage.Next(50) + num), 1f); SolidBrush solidBrush = new SolidBrush(Color.FromArgb(VerifyImage.Next(100), VerifyImage.Next(100), VerifyImage.Next(100))); for (int i = 0; i < 3; i++) { graphics.DrawArc(pen, VerifyImage.Next(20) - 10, VerifyImage.Next(20) - 10, VerifyImage.Next(width) + 10, VerifyImage.Next(height) + 10, VerifyImage.Next(-100, 100), VerifyImage.Next(-200, 200)); } for (int j = 0; j < code.Length; j++) { solidBrush = new SolidBrush(Color.Black); PointF point = new PointF((float)j * 7.2f + 4.2f, 2.6f); graphics.DrawString(code[j].ToString(), VerifyImage.font, solidBrush, point); } solidBrush.Dispose(); graphics.Dispose(); verifyImageInfo.Image = image; return(verifyImageInfo); }
private static int Next(int min, int max) { return(VerifyImage.Next(max - min) + min); }