Exemple #1
0
 private void OnImageToBackBone(object sender, System.EventArgs e)
 {
     m_Undo = (Bitmap)m_Bitmap.Clone();
     FontMethods.ImageToBackBone(m_Bitmap);
     m_Bitmap               = FontMethods.BoundCore(m_Bitmap);
     this.AutoScroll        = true;
     this.AutoScrollMinSize = new Size((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
     this.Invalidate();
 }
Exemple #2
0
        private void OnRank(object sender, System.EventArgs e)
        {
            m_Undo = (Bitmap)m_Bitmap.Clone();
            BitmapFilter.GrayToBlack(m_Bitmap, BRIGHT);
            Bitmap[]   arr = FontMethods.ImageToTextR1(m_Bitmap);
            Bitmap[][] br  = new Bitmap[arr.Length][];
            Bitmap[]   cr  = new Bitmap[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                br[i] = FontMethods.ImageToTextR2(arr[i]);
                cr[i] = FontMethods.JoinBitmap(br[i]);
            }
            m_Bitmap               = FontMethods.JoinBitmapH(cr);
            this.AutoScroll        = true;
            this.AutoScrollMinSize = new Size((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
            this.Invalidate();

            Bitmap[][] brcop   = new Bitmap[arr.Length][];
            List <ABC> listABC = new List <ABC>();

            for (int i = 0; i < arr.Length; i++)
            {
                Bitmap[] bbcop = new Bitmap[br[i].Length];
                for (int j = 0; j < br[i].Length; j++)
                {
                    bbcop[j] = (Bitmap)br[i][j].Clone();
                    bbcop[j] = FontMethods.BoundCore(bbcop[j]);
                    int[] fra = FontMethods.Fragment(bbcop[j]);

                    //FontMethods.ImageToBackBone(br[i][j]);
                    br[i][j] = FontMethods.BoundCore(br[i][j]);
                    double[]   d      = FontMethods.AverageSquare(br[i][j]);
                    double[][] ad     = FontMethods.Margin(br[i][j]);
                    ABC        strABC = new ABC();
                    strABC.AverageSquare    = d;
                    strABC.ProportionSquare = strABC.AverageSquare[1] == 0 ? 0 : strABC.AverageSquare[0] / strABC.AverageSquare[1];
                    strABC.Margin           = ad;
                    strABC.Fragment         = fra;
                    listABC.Add(strABC);
                }
            }
            string mes = String.Join("\n", listABC);

            Clipboard.SetText(mes);
            MessageBox.Show(mes);
        }
Exemple #3
0
        private void OnAverageSquare(object sender, System.EventArgs e)
        {
            m_Undo = FontMethods.BoundCore(m_Undo);
            int[] fra = FontMethods.Fragment(m_Undo);
            //already run OnImageToBackBone
            double[]   d   = FontMethods.AverageSquare(m_Bitmap);
            double[][] ad  = FontMethods.Margin(m_Bitmap);
            string     mes = d[0].ToString() + ":" + d[1].ToString() + ":" + d[2].ToString()
                             + ":[" + ad[0][0].ToString("0.00000") + ":" + ad[0][1].ToString("0.00000") + "]"
                             + ":[" + ad[1][0].ToString("0.00000") + ":" + ad[1][1].ToString("0.00000") + "]"
                             + ":[" + ad[2][0].ToString("0.00000") + ":" + ad[2][1].ToString("0.00000") + "]"
                             + ":[" + ad[3][0].ToString("0.00000") + ":" + ad[3][1].ToString("0.00000") + "]"
                             + ":[" + ad[4][0].ToString("0.00000") + ":" + ad[4][1].ToString("0.00000") + "]"
                             + ":[" + ad[5][0].ToString("0.00000") + ":" + ad[5][1].ToString("0.00000") + "]"
                             + ":[" + ad[6][0].ToString("0.00000") + ":" + ad[6][1].ToString("0.00000") + "]"
                             + ":[" + ad[7][0].ToString("0.00000") + ":" + ad[7][1].ToString("0.00000") + "]"
                             + ":" + String.Join(",", fra);

            Clipboard.SetText(mes);
            MessageBox.Show(mes);
        }
Exemple #4
0
        private void OnDictionary(object sender, System.EventArgs e)
        {
            string[]   arrdic  = new String[] { "田", "字", "奉", "膂", "雪", "こ", "や", "至", "一", "雪", "雪", "だ", "や", "ほ", "’", "ん", "と", "や" };
            Bitmap[]   br      = new Bitmap[arrdic.Length];
            Bitmap[]   brcop   = new Bitmap[arrdic.Length];
            List <ABC> listABC = new List <ABC>();

            for (int i = 0; i < arrdic.Length; i++)
            {
                br[i] = (Bitmap)FontMethods.Render(arrdic[i]);
                BitmapFilter.GrayToBlack(br[i], BRIGHT);
                brcop[i] = (Bitmap)br[i].Clone();
                brcop[i] = FontMethods.BoundCore(brcop[i]);
                int[] fra = FontMethods.Fragment(brcop[i]);

                //FontMethods.ImageToBackBone(br[i]);
                br[i] = FontMethods.BoundCore(br[i]);
                double[]   d      = FontMethods.AverageSquare(br[i]);
                double[][] ad     = FontMethods.Margin(br[i]);
                ABC        strABC = new ABC();
                strABC.KEY              = arrdic[i];
                strABC.AverageSquare    = d;
                strABC.ProportionSquare = strABC.AverageSquare[1] == 0 ? 0 : strABC.AverageSquare[0] / strABC.AverageSquare[1];
                strABC.Margin           = ad;
                strABC.Fragment         = fra;
                listABC.Add(strABC);
            }

            m_Bitmap               = FontMethods.JoinBitmap(brcop);
            this.AutoScroll        = true;
            this.AutoScrollMinSize = new Size((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
            this.Invalidate();

            string mes = String.Join("\n", listABC);

            Clipboard.SetText(mes);
            MessageBox.Show(mes);
        }
Exemple #5
0
        private void OnSynthetic(object sender, System.EventArgs e)
        {
            List <ABC> des    = new List <ABC>();
            List <ABC> predic = new List <ABC>();

            int im = 0;

            if (im == 0)
            {
                string[]   arrdic  = new String[] { "田", "字", "奉", "膂", "雪", "こ", "や", "至", "一", "だ", "ほ", "’", "ん", "と" };
                Bitmap[]   br      = new Bitmap[arrdic.Length];
                Bitmap[]   brcop   = new Bitmap[arrdic.Length];
                List <ABC> listABC = new List <ABC>();

                for (int i = 0; i < arrdic.Length; i++)
                {
                    br[i] = (Bitmap)FontMethods.Render(arrdic[i]);
                    BitmapFilter.GrayToBlack(br[i], BRIGHT);
                    brcop[i] = (Bitmap)br[i].Clone();
                    brcop[i] = FontMethods.BoundCore(brcop[i]);
                    int[] fra = FontMethods.Fragment(brcop[i]);

                    //FontMethods.ImageToBackBone(br[i]);
                    br[i] = FontMethods.BoundCore(br[i]);
                    double[]   d      = FontMethods.AverageSquare(br[i]);
                    double[][] ad     = FontMethods.Margin(br[i]);
                    ABC        strABC = new ABC();
                    strABC.KEY              = arrdic[i];
                    strABC.AverageSquare    = d;
                    strABC.ProportionSquare = strABC.AverageSquare[1] == 0 ? 0 : strABC.AverageSquare[0] / strABC.AverageSquare[1];
                    strABC.Margin           = ad;
                    strABC.Fragment         = fra;
                    listABC.Add(strABC);
                }
                predic = listABC;
            }

            im = 1;
            if (im == 1)
            {
                m_Undo = (Bitmap)m_Bitmap.Clone();
                BitmapFilter.GrayToBlack(m_Bitmap, BRIGHT);
                Bitmap[]   arr = FontMethods.ImageToTextR1(m_Bitmap);
                Bitmap[][] br  = new Bitmap[arr.Length][];
                Bitmap[]   cr  = new Bitmap[arr.Length];
                for (int i = 0; i < arr.Length; i++)
                {
                    br[i] = FontMethods.ImageToTextR2(arr[i]);
                    cr[i] = FontMethods.JoinBitmap(br[i]);
                }
                m_Bitmap               = FontMethods.JoinBitmapH(cr);
                this.AutoScroll        = true;
                this.AutoScrollMinSize = new Size((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
                this.Invalidate();

                Bitmap[][] brcop   = new Bitmap[arr.Length][];
                List <ABC> listABC = new List <ABC>();
                for (int i = 0; i < arr.Length; i++)
                {
                    Bitmap[] bbcop = new Bitmap[br[i].Length];
                    for (int j = 0; j < br[i].Length; j++)
                    {
                        bbcop[j] = (Bitmap)br[i][j].Clone();
                        bbcop[j] = FontMethods.BoundCore(bbcop[j]);
                        int[] fra = FontMethods.Fragment(bbcop[j]);

                        //FontMethods.ImageToBackBone(br[i][j]);
                        br[i][j] = FontMethods.BoundCore(br[i][j]);
                        double[]   d      = FontMethods.AverageSquare(br[i][j]);
                        double[][] ad     = FontMethods.Margin(br[i][j]);
                        ABC        strABC = new ABC();
                        strABC.AverageSquare    = d;
                        strABC.ProportionSquare = strABC.AverageSquare[1] == 0 ? 0 : strABC.AverageSquare[0] / strABC.AverageSquare[1];
                        strABC.Margin           = ad;
                        strABC.Fragment         = fra;
                        listABC.Add(strABC);
                    }
                }
                des = listABC;
            }
            FncSynthetic(des, predic);
        }