예제 #1
0
        private static float FontSize(FontWarpFactor fontWarpFactor, int height)
        {
            float size = 0f;

            switch (fontWarpFactor)
            {
            case FontWarpFactor.None:
                size = height * 0.7f;
                break;

            case FontWarpFactor.Low:
                size = height * 0.8f;
                break;

            case FontWarpFactor.Medium:
                size = height * 0.85f;
                break;

            case FontWarpFactor.High:
                size = height * 0.9f;
                break;
            }

            return(size);
        }
예제 #2
0
        private static Pair <float> WarpMutipliers(FontWarpFactor fontWarpFactor)
        {
            float m1 = 1f;
            float m2 = 1f;

            switch (fontWarpFactor)
            {
            case FontWarpFactor.None:
                break;

            case FontWarpFactor.Low:
                m1 = 6f;
                m2 = 1f;
                break;

            case FontWarpFactor.Medium:
                m1 = 5f;
                m2 = 1.3f;
                break;

            case FontWarpFactor.High:
                m1 = 4.5f;
                m2 = 1.4f;
                break;
            }

            return(new Pair <float>(m1, m2));
        }
예제 #3
0
 public CaptchaImage()
 {
     _rand             = new Random();
     _fontWarp         = FontWarpFactor.Low;
     _backgroundNoise  = BackgroundNoiseLevel.Low;
     _lineNoise        = LineNoiseLevel.None;
     _width            = 180;
     _height           = 50;
     _randomTextLength = 5;
     _randomTextChars  = "ACDEFGHJKLNPQRTUVXYZ2346789";
     _fontFamilyName   = "";
     // -- a list of known good fonts in on both Windows XP and Windows Server 2003
     _fontWhitelist = "arial;arial black;comic sans ms;courier new;estrangelo edessa;franklin gothic medium;" + "georgia;lucida console;lucida sans unicode;mangal;microsoft sans serif;palatino linotype;" + "sylfaen;tahoma;times new roman;trebuchet ms;verdana";
     Refresh();
 }
예제 #4
0
 public WarpTextDrawing(int width, int height, string fonts, Color textColor, FontWarpFactor fontWarpFactor)
 {
     m_width     = width;
     m_height    = height;
     m_fonts     = ParseFonts(fonts);
     m_textColor = textColor;
     m_fontSize  = FontSize(fontWarpFactor, height);
     if (fontWarpFactor != FontWarpFactor.None)
     {
         var m = WarpMutipliers(fontWarpFactor);
         m_warpMultiplier1 = m.First;
         m_warpMultiplier2 = m.Second;
         m_strategy        = WarpText;
     }
 }
예제 #5
0
 public CaptchaImage()
 {
     _rand = new Random();
     _fontWarp = FontWarpFactor.Low;
     _backgroundNoise = BackgroundNoiseLevel.Low;
     _lineNoise = LineNoiseLevel.None;
     _width = 180;
     _height = 50;
     _randomTextLength = 5;
     _randomTextChars = "ACDEFGHJKLNPQRTUVXYZ2346789";
     _fontFamilyName = "";
     // -- a list of known good fonts in on both Windows XP and Windows Server 2003
     _fontWhitelist = "arial;arial black;comic sans ms;courier new;estrangelo edessa;franklin gothic medium;" + "georgia;lucida console;lucida sans unicode;mangal;microsoft sans serif;palatino linotype;" + "sylfaen;tahoma;times new roman;trebuchet ms;verdana";
     _randomText = GenerateRandomText();
     _generatedAt = DateTime.Now;
     _guid = Guid.NewGuid().ToString();
 }
예제 #6
0
 public Variant12()
 {
     m_rand             = new Random();
     m_fontWarp         = FontWarpFactor.Low;
     m_backgroundNoise  = BackgroundNoiseLevel.Low;
     m_lineNoise        = LineNoiseLevel.None;
     m_width            = 180;
     m_height           = 50;
     m_randomTextLength = 5;
     m_randomTextChars  = "ACDEFGHJKLNPQRTUVXYZ2346789";
     m_fontFamilyName   = "";
     // -- a list of known good fonts in on both Windows XP and Windows Server 2003
     m_fontWhitelist = "arial;arial black;comic sans ms;courier new;estrangelo edessa;franklin gothic medium;" + "georgia;lucida console;lucida sans unicode;mangal;microsoft sans serif;palatino linotype;" + "sylfaen;tahoma;times new roman;trebuchet ms;verdana";
     m_randomText    = GenerateRandomText();
     m_generatedAt   = DateTime.Now;
     m_guid          = Guid.NewGuid().ToString();
 }
예제 #7
0
 public CaptchaImage(Color line, Color text, Color background)
 {
     _rand             = new Random();
     _fontWarp         = FontWarpFactor.High;
     _backgroundNoise  = BackgroundNoiseLevel.None;
     _lineNoise        = LineNoiseLevel.High;
     _width            = 180;
     _height           = 50;
     _randomTextLength = 3;
     _randomTextChars  = "012346789";
     _fontFamilyName   = "";
     // -- a list of known good fonts in on both Windows XP and Windows Server 2003
     _fontWhitelist = "arial;arial black;comic sans ms;courier new;estrangelo edessa;franklin gothic medium;" + "georgia;lucida console;lucida sans unicode;mangal;microsoft sans serif;palatino linotype;" + "sylfaen;tahoma;times new roman;trebuchet ms;verdana";
     _randomText    = GenerateRandomText();
     _generatedAt   = DateTime.Now;
     _guid          = Guid.NewGuid().ToString();
     _line          = line;
     _text          = text;
     _background    = background;
 }