示例#1
0
 public ASCIIWeightCalc(int fontsize, ASCIICategories categories)
 {
     _fontsize     = fontsize;
     _textCoord    = new Point(0, 0);
     _font         = new Font(FontFamily.GenericMonospace, _fontsize);
     CharsWeighted = CalculateWeights(categories);
 }
示例#2
0
        public GifConverter(Image gif, int teiler, int fontsize, ASCIICategories categories)
        {
            Gif = gif;

            Font                = new Font(FontFamily.GenericMonospace, fontsize);
            _converter          = new PicConverter(teiler, fontsize, categories);
            _bitmapFontSizeCalc = new BitmapFontSizeCalc(fontsize, Font);
        }
示例#3
0
 public PicConverter(int teiler, int fontsize, ASCIICategories categories, bool savetxt)
 {
     Teiler     = teiler;
     WeightCalc = new ASCIIWeightCalc(fontsize, categories);
     SaveTxt    = savetxt;
 }
示例#4
0
 public PicConverter(int teiler, int fontsize, ASCIICategories categories) : this(teiler, fontsize, categories, false)
 {
 }
示例#5
0
        private List <char> CalculateWeights(ASCIICategories categories)
        {
            var dict = new Dictionary <char, double>();

            void addFromXtoY(int x, int y)
            {
                for (int i = x; i <= y; i++)
                {
                    char c = (char)i;
                    dict.Add(c, BlackWhiteValue(DrawChar(c)));
                }
            }

            if (categories.LowerCase)
            {
                addFromXtoY(97, 122);
            }
            if (categories.UpperCase)
            {
                addFromXtoY(65, 90);
            }
            if (categories.Numbers)
            {
                addFromXtoY(48, 57);
            }
            if (categories.SpecialChars1)
            {
                addFromXtoY(32, 47);
            }
            if (categories.SpecialChars2)
            {
                addFromXtoY(58, 63);
            }
            if (categories.SpecialChars3)
            {
                addFromXtoY(91, 95);
                addFromXtoY(123, 126);
            }
            if (categories.SpecialChars4)
            {
                addFromXtoY(128, 254);
            }


            dict = dict.OrderByDescending(keypair => keypair.Value)
                   .ToDictionary(keypair => keypair.Key, keypair => keypair.Value);

            List <double> werts = new List <double>();
            List <char>   list  = new List <char>();

            //kein foreach, weil sonst reihenfolge verloren gehen könnte
            for (int i = 0; i < dict.Count; i++)
            {
                if (!werts.Contains(dict.ElementAt(i).Value))
                {
                    werts.Add(dict.ElementAt(i).Value);
                    list.Add(dict.ElementAt(i).Key);
                }
            }
            EvaluatedCharsCount    = dict.Count;
            UniqueWeightCharsCount = list.Count;
            return(list);
        }