}        //Legature

        public void addDiacritic(Diacritics inpDc)
        {
            DcNode temp = new DcNode();

            temp.name = (string)inpDc.name.Clone();
            if (inpDc.location < 0)
            {
                temp.name = string.Concat(temp.name, " below");
            }
            else
            {
                temp.name = string.Concat(temp.name, " above");
            }
            temp.x = (inpDc.RightMostPoint - inpDc.LeftMostPoint) / 2 + inpDc.LeftMostPoint;

            if (this.dcList == null)
            {
                this.dcList = temp;
            }
            else
            {
                DcNode iterator = this.dcList;
                if (temp.x > iterator.x)
                {
                    temp.next   = iterator;
                    this.dcList = temp;
                }
                else
                {
                    while (iterator.next != null)
                    {
                        if (temp.x > iterator.next.x)
                        {
                            temp.next     = iterator.next;
                            iterator.next = temp;
                            break;
                        }
                        iterator = iterator.next;
                    }                    //while
                    if (iterator.next == null)
                    {
                        iterator.next = temp;
                    }
                } //else
            }     //else
        }         //addDiacritic()
예제 #2
0
        public void labeleLegature()
        {
            Legature   T_Leg;
            Diacritics T_Diacritic;
            string     temp  = null;
            byte       label = 2;
            int        i     = 0;
            int        j     = 0;
            int        lmp;          //left most point
            int        rmp;          //right most point
            int        tmp;          //top most point
            int        bmp;          //bottom most point
            int        legArea  = 0; //legatre area i.e. total number of dots forming legature
            int        baseBand = 10;

            Form2 F = new Form2();            //to b deleted if necessory

            loadDiacriticalTemplates();

            //iterate in the base band to seperate the main body legatures in their order of existance
            for (j = this.width - 2; j > 0; j--)
            {
                for (i = this.baseLine - baseBand; i <= this.baseLine; i++)
                {
                    if (this.array[i, j] == 0)
                    {
                        rmp     = j;
                        lmp     = j;
                        tmp     = i;
                        bmp     = i;
                        legArea = 0;
                        _8ConnectedMethod(j, i, label, ref rmp, ref lmp, ref tmp, ref bmp, ref legArea);
                        temp = null;
                        if (legArea <= this.maxD_size && (bmp - tmp) <= this.maxD_height && (rmp - lmp) <= this.maxD_width)
                        {
                            temp = compareDiacritic(label, rmp, lmp, tmp, bmp);
                            if (temp.CompareTo("mad") == 0 || temp.CompareTo("hamza") == 0)
                            {
                                T_Leg = new Legature(getmainBody(label, rmp, lmp, tmp, bmp), rmp, lmp, tmp, bmp, legArea);
                                this.ligatureLsit.addObject(T_Leg);
                            }                            //if
                            else
                            {
                                bool _3dFlag = false;
                                if (temp.CompareTo("one dot") == 0 || temp.CompareTo("two dot") == 0)
                                {
                                    _3dFlag = check_and_set_threedots(temp, rmp, lmp, tmp, bmp);
                                }                                //if
                                if (_3dFlag == false)
                                {
                                    if (temp.CompareTo("shad") == 0)                                 //shad always comes above
                                    {
                                        T_Diacritic = new Diacritics(temp, rmp, lmp, tmp, bmp, 1);
                                    }
                                    else
                                    {
                                        T_Diacritic = new Diacritics(temp, rmp, lmp, tmp, bmp, getPosition(label, (rmp - lmp) / 2 + lmp, (bmp - tmp) / 2 + tmp));
                                    }
                                    this.diacritics.addObject(T_Diacritic);
                                }                //if
                            }                    //else
                        }                        //if
                        else
                        {
                            T_Leg = new Legature(getmainBody(label, rmp, lmp, tmp, bmp), rmp, lmp, tmp, bmp, legArea);
                            this.ligatureLsit.addObject(T_Leg);
                        }                        //else

/*						Bitmap leg = new System.Drawing.Bitmap(1+rmp-lmp,1+bmp-tmp);
 *                                              int w=lmp;
 *                                              int h=tmp;
 *                                              for(int l=0;l<leg.Width;l++)
 *                                              {
 *                                                      h=tmp;
 *                                                      for(int m = 0; m<leg.Height;m++)
 *                                                      {
 *                                                              if(this.array[h,w]==label)
 *                                                                      leg.SetPixel(l,m,System.Drawing.Color.Black);
 *                                                              else
 *                                                                      leg.SetPixel(l,m,System.Drawing.Color.White);
 *                                                              h++;
 *                                                      }//for
 *                                                      w++;
 *                                              }//for
 *
 *                                              F.pictureBox1.Image = leg;
 *                                              F.pictureBox1.Show();
 *                                              F.textBox1.Text = temp;
 *                                              F.ShowDialog();
 */
                        label++;
                    }    //else if
                }        //for
            }            //for

            //iterate in the whole line to seperate diacritical legatures that were missed in above iteration
            for (j = this.width - 2; j > 0; j--)
            {
                for (i = 1; i < this.height - 1; i++)
                {
                    if (this.array[i, j] == 0)
                    {
                        rmp     = j;
                        lmp     = j;
                        tmp     = i;
                        bmp     = i;
                        legArea = 0;
                        _8ConnectedMethod(j, i, label, ref rmp, ref lmp, ref tmp, ref bmp, ref legArea);
                        temp = null;
                        if (legArea <= this.maxD_size && (bmp - tmp) <= this.maxD_height && (rmp - lmp) <= this.maxD_width)
                        {
                            bool _3dFlag = false;
                            temp = compareDiacritic(label, rmp, lmp, tmp, bmp);
                            if (temp.CompareTo("one dot") == 0 || temp.CompareTo("two dot") == 0)
                            {
                                _3dFlag = check_and_set_threedots(temp, rmp, lmp, tmp, bmp);
                            }
                            if (_3dFlag == false)
                            {
                                if (temp.CompareTo("shad") == 0)                             //shad always comes above
                                {
                                    T_Diacritic = new Diacritics(temp, rmp, lmp, tmp, bmp, 1);
                                }
                                else
                                {
                                    T_Diacritic = new Diacritics(temp, rmp, lmp, tmp, bmp, this.getPosition(label, (rmp - lmp) / 2 + lmp, (bmp - tmp) / 2 + tmp));
                                }
                                this.diacritics.addObject(T_Diacritic);
                            }                    //if
                        }                        //if
                        else
                        {
                            T_Leg = new Legature(getmainBody(label, rmp, lmp, tmp, bmp), rmp, lmp, tmp, bmp, legArea);
                            this.ligatureLsit.addObject(T_Leg);
                        }                        //else

/*						Bitmap leg = new System.Drawing.Bitmap(1+rmp-lmp,1+bmp-tmp);
 *                                              int w=lmp;
 *                                              int h=tmp;
 *                                              for(int l=0;l<leg.Width;l++)
 *                                              {
 *                                                      h=tmp;
 *                                                      for(int m = 0; m<leg.Height;m++)
 *                                                      {
 *                                                              if(this.array[h,w]==label)
 *                                                                      leg.SetPixel(l,m,System.Drawing.Color.Black);
 *                                                              else
 *                                                                      leg.SetPixel(l,m,System.Drawing.Color.White);
 *                                                              h++;
 *                                                      }//for
 *                                                      w++;
 *                                              }//for
 *
 *                                              F.pictureBox1.Image = leg;
 *                                              F.pictureBox1.Show();
 *                                              F.textBox1.Text = temp;
 *                                              F.ShowDialog();
 */
                        label++;
                    } //else if
                }     //for
            }         //for
        }             //labelLegature