Пример #1
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                reset();
                init();

                //Open the browsed image and display it
                string OpenedFilePath = openFileDialog1.FileName;
                ImageMatrix = ImageOperations.OpenImage(OpenedFilePath);
                helper.set_boundries(ImageMatrix.GetLength(0), ImageMatrix.GetLength(1));  // row , col

                /*
                 *  I think this step just have the aim of getting the pixel of where the
                 */
                ImageOperations.DisplayImage(ImageMatrix, pictureBox1);

                int sz = ImageMatrix.GetLength(0) * ImageMatrix.GetLength(1);
                g = new graph(sz);                     // special case of init();

                g.set_width(ImageMatrix.GetLength(1)); // 1 is width = number of columns

                //g.build(ImageMatrix);  // cuz time delay
                ok = true;
            }
            // GUI Stuff
            txtWidth.Text  = ImageOperations.GetWidth(ImageMatrix).ToString();
            txtHeight.Text = ImageOperations.GetHeight(ImageMatrix).ToString();
        }
Пример #2
0
        /*
         *  list have the ID of pixels
         *  pring pixels itself
         *  construct points
         *  draw curve passing by them
         */
        public void draw_line(List <int> l, graph g, System.Windows.Forms.PictureBox pictureBox1)
        {
            assign(l);
            Point[] points = new Point[orginal_path.Count + l.Count];
            // draw main path
            int i = 0;

            for (; i < orginal_path.Count; i++)
            {
                int   tid  = orginal_path[i];
                pixel tmp1 = helper.un_flatten(tid, g.width);
                Point tmp2 = new Point(tmp1.y, tmp1.x);  // col , row
                points[i] = tmp2;
            }

            // draw tmp temporary path
            for (int j = 0; j < tmp_path.Count; j++)
            {
                int   tid  = tmp_path[j];
                pixel tmp1 = helper.un_flatten(tid, g.width);
                Point tmp2 = new Point(tmp1.y, tmp1.x); // col , row
                points[i++] = tmp2;
            }
            if (points.Length >= 2)  // draw the whole curve
            {
                pictureBox1.Refresh();
                MainForm.gr.DrawCurve(MainForm.p, points);
            }
        }
Пример #3
0
 // end
 void reset()
 {
     g           = null;
     p           = null;
     gr          = null;
     draw_cutter = null;
     ok          = false;
     mov         = false;
     constructed = false;
 }