private void GetBitmap_WhitePoly(Image bm, sudokuImg si)
        {
            using (var g = Graphics.FromImage(bm)) {
                g.DrawPolygon(new Pen(Color.Red, 2), si.whitePolygon);

                /*g.DrawLine(new Pen(Color.Blue, 2), 0, si.topWhiteLine.y(0), bm.Width, si.topWhiteLine.y(bm.Width));
                 * g.DrawLine(new Pen(Color.Blue, 2), 0, si.bottomWhiteLine.y(0), bm.Width, si.bottomWhiteLine.y(bm.Width));
                 * g.DrawLine(new Pen(Color.Blue, 2), si.leftWhiteLine.x(0), 0, si.leftWhiteLine.x(bm.Height), bm.Height);
                 * g.DrawLine(new Pen(Color.Blue, 2), si.rightWhiteLine.x(0), 0, si.rightWhiteLine.x(bm.Height), bm.Height);*/
            }
        }
 private void GetBitmap_RotateLine(Image bm, sudokuImg si)
 {
     using (var g = Graphics.FromImage(bm)) {
         g.DrawLine(new Pen(Color.Red, 2), 5, 0, 0, 5);
         int x0 = bm.Width / 3, x1 = 2 * (bm.Width / 3), y0 = bm.Height / 3, y1 = 2 * (bm.Height / 3);
         g.DrawRectangle(new Pen(Color.DeepSkyBlue, 1), x0, y0, x0, y0);
         if (si.MaxLine.Th == 0)
         {
             g.DrawLine(_rotateLinePen, si.MaxLine.Rh, y0, si.MaxLine.Rh, y1);
         }
         else
         {
             g.DrawLine(_rotateLinePen, 0, si.MaxLine.Rh / Acc.Sins[si.MaxLine.Th], bm.Width, (si.MaxLine.Rh - bm.Width * Acc.Coss[si.MaxLine.Th]) / Acc.Sins[si.MaxLine.Th]);
         }
     }
 }
        private void GetBitmap_SudokuLines(Image bm, sudokuImg si)
        {
            using (var g = Graphics.FromImage(bm)) {
                if (si.horLines[0] == null)
                {
                    return;
                }
                try {
                    //g.DrawRectangle(new Pen(Color.Brown, 2), si.rectL);
                    //g.DrawLine(new Pen(Color.Blue, 2), 0, si.horLines[0].y(0), bm.Width, si.horLines[0].y(bm.Width));
                    //MessageBox.Show(si.verLines[0].x(0) + "  " + si.verLines[0].y(bm.Height) + "   " + bm.Height);

                    /*for (int i = 0; i < 4; i++) {
                     *  g.DrawLine(new Pen(Color.Blue, 2), si.verLines[i * 3].x(0), 0, si.verLines[i * 3].x(bm.Height), bm.Height);
                     *  g.DrawLine(new Pen(Color.Blue, 2), 0, si.horLines[i * 3].y(0), bm.Width, si.horLines[i * 3].y(bm.Width));
                     * }*/
                    for (int i = 0; i < 10; i++)
                    {
                        g.DrawLine(new Pen(Color.Blue, 2), si.dots[0, i].X, si.dots[0, i].Y, si.dots[9, i].X, si.dots[9, i].Y);
                        g.DrawLine(new Pen(Color.Blue, 2), si.dots[i, 0].X, si.dots[i, 0].Y, si.dots[i, 9].X, si.dots[i, 9].Y);
                    }
                    //for (int i = 0; i < 10; i++) {

                    /*int j = 2;
                     *  for (int i = 0; i < 10; i++) {
                     *      g.DrawLine(new Pen(Color.Blue, 2), si.dots[i, j].X-3, si.dots[i, j].Y, si.dots[i, j].X+3, si.dots[i, j].Y);
                     *  }*/
                    //}
                }
                catch (Exception e) { }

                /*g.DrawLine(new Pen(Color.Blue, 2), 0, si.topWhiteLine.y(0), bm.Width, si.topWhiteLine.y(bm.Width));
                 * g.DrawLine(new Pen(Color.Blue, 2), 0, si.bottomWhiteLine.y(0), bm.Width, si.bottomWhiteLine.y(bm.Width));
                 * g.DrawLine(new Pen(Color.Blue, 2), si.leftWhiteLine.x(0), 0, si.leftWhiteLine.x(bm.Height), bm.Height);
                 * g.DrawLine(new Pen(Color.Blue, 2), si.rightWhiteLine.x(0), 0, si.rightWhiteLine.x(bm.Height), bm.Height);*/
            }
        }
        private void GetBitmap_SudokuCif(Image bm, sudokuImg si)
        {
            using (var g = Graphics.FromImage(bm)) {
                if (si.horLines[0] == null)
                {
                    return;
                }
                try {
                    //g.DrawRectangle(new Pen(Color.Brown, 2), si.rectL);
                    //g.DrawLine(new Pen(Color.Blue, 2), 0, si.horLines[0].y(0), bm.Width, si.horLines[0].y(bm.Width));
                    //MessageBox.Show(si.verLines[0].x(0) + "  " + si.verLines[0].y(bm.Height) + "   " + bm.Height);

                    /*for (int i = 0; i < 4; i++) {
                     *  g.DrawLine(new Pen(Color.Blue, 2), si.verLines[i * 3].x(0), 0, si.verLines[i * 3].x(bm.Height), bm.Height);
                     *  g.DrawLine(new Pen(Color.Blue, 2), 0, si.horLines[i * 3].y(0), bm.Width, si.horLines[i * 3].y(bm.Width));
                     * }*/
                    for (int i = 0; i < 9; i++)
                    {
                        for (int j = 0; j < 9; j++)
                        {
                            if (si.chi[i, j] <= 0)
                            {
                                continue;
                            }
                            g.DrawString(si.chi[i, j] + "", new Font(FontFamily.GenericSansSerif, 20), new SolidBrush(Color.Red), si.dots[i, j].X, si.dots[i, j].Y - 30);
                        }
                    }
                }
                catch (Exception e) { }

                /*g.DrawLine(new Pen(Color.Blue, 2), 0, si.topWhiteLine.y(0), bm.Width, si.topWhiteLine.y(bm.Width));
                 * g.DrawLine(new Pen(Color.Blue, 2), 0, si.bottomWhiteLine.y(0), bm.Width, si.bottomWhiteLine.y(bm.Width));
                 * g.DrawLine(new Pen(Color.Blue, 2), si.leftWhiteLine.x(0), 0, si.leftWhiteLine.x(bm.Height), bm.Height);
                 * g.DrawLine(new Pen(Color.Blue, 2), si.rightWhiteLine.x(0), 0, si.rightWhiteLine.x(bm.Height), bm.Height);*/
            }
        }
        unsafe private void GetBitmap_White(ref byte[] imgBytes, sudokuImg si)
        {
            var mbm = si.MBM;

            fixed(byte *firstImgByte = &imgBytes[0]) fixed(bool *firstMBMRef = &mbm[0, 0])
            {
                var fib = firstImgByte;
                var fmr = firstMBMRef;

                for (var i = 0; i < imgBytes.Length / 3; i++)
                {
                    if (*fmr++)
                    {
                        fib += 3;
                    }
                    else
                    {
                        *fib++ = 0xFF;
                        *fib++ = 0xFF;
                        *fib++ = 0xFF;
                    }
                }
            }
        }