Exemplo n.º 1
0
        //Colour matching algorithim
        private FCell matchFast(Cell input)
        {
            FCell result = new FCell();
            result.character = 177;
            result.colour1 = 0;
            result.colour2 = 0;
            int diff = 0;
            int min = int.MaxValue;
            Color avg = avgColour(input);

            for (int i = 0; i < 136; i++)
            {
                diff = Math.Abs(avgs[i].avg.R - avg.R) + Math.Abs(avgs[i].avg.G - avg.G) + Math.Abs(avgs[i].avg.B - avg.B);
                if (diff < min)
                {
                    min = diff;
                    result.colour1 = avgs[i].colour1;
                    result.colour2 = avgs[i].colour2;
                }
            }
            return result;
        }
Exemplo n.º 2
0
        private FCell matchSlow(Cell input, int i)
        {
            FCell result = new FCell();
            result.character = 0;
            result.colour1 = 0;
            result.colour2 = 13;
            //find most popular colours

            int diff1;
            int diff2;
            int min = int.MaxValue;
            byte[] mcommon = getMCommon(input);
            for (int cha = 3; cha < 255; cha++)
            {
                diff1 = 0;
                diff2 = 0;
                //only two things to try here.
                for (int pixel = 0; pixel < 64; pixel++)
                {
                        if (fonts[i].getPix(cha, pixel))
                        {
                            diff1 += Math.Abs(input.getPix(pixel).R - colours[mcommon[0]].R) + Math.Abs(input.getPix(pixel).G - colours[mcommon[0]].G) + Math.Abs(input.getPix(pixel).B - colours[mcommon[0]].B); //0 and 1
                            diff2 += Math.Abs(input.getPix(pixel).R - colours[mcommon[1]].R) + Math.Abs(input.getPix(pixel).G - colours[mcommon[1]].G) + Math.Abs(input.getPix(pixel).B - colours[mcommon[1]].B); //1 and 0

                        }
                        else
                        {
                            diff1 += Math.Abs(input.getPix(pixel).R - colours[mcommon[1]].R) + Math.Abs(input.getPix(pixel).G - colours[mcommon[1]].G) + Math.Abs(input.getPix(pixel).B - colours[mcommon[1]].B); //0 and 1
                            diff2 += Math.Abs(input.getPix(pixel).R - colours[mcommon[0]].R) + Math.Abs(input.getPix(pixel).G - colours[mcommon[0]].G) + Math.Abs(input.getPix(pixel).B - colours[mcommon[0]].B); //1 and 0
                        }
                }
                if (diff1 < min)
                {
                    min = diff1;
                    result.character = (byte)cha;
                    result.colour1 = (byte)mcommon[0];
                    result.colour2 = (byte)mcommon[1];
                }

                if (diff2 < min)
                {
                    min = diff2;
                    result.character = (byte)cha;
                    result.colour1 = (byte)mcommon[1];
                    result.colour2 = (byte)mcommon[0];
                }

            }
            return result;
        }
Exemplo n.º 3
0
 public void setCell(FCell cell, int index)
 {
     cells[index] = cell;
 }