際際滷

際際滷Share a Scribd company logo
鏃荷             惘                    悋

                                                                                 悋慍

                           悋             悋                             悋           悋        悋                              悋惠       惆

                                 悋 惘                  TextBoxes                              悋 惘                      悋        悋

                   惘慍 惠          悋                           悋 悋              悋 悋 悋

                                         慍悋                             TextBoxes                           悋 攵        悋

                                         PictureBox                                                  攵

悋   攵   悋     悋                   惘慍      悋           惆              悋      悋 悋 悋                   悋                                   Button   攵       
                                                            悋                      悋  

                                         惺 悋Form             悋 Design                   惆 悋            悋     愀




                                                                         攵         惆        悋

悋PictureBox                       惘慍        悋   攵                     攵                     悋  Button悋                            悋       悋                攵

            悋Button                       攵      惆悋    悋                        惆悋                 攵              悋  Button惆                 攵


                                                   悋                惆 惆 攵      悋悋

                                   悋          攵   悋      悋           惠攵         悋          悋

                              悋 慍悋 悋            悋 TextBoxes      惠悋 惆                                       悋     1. 攵
                                                 悋 惘慍     悋惆     2. 
                                             惘悸         惘慍 惆 攵     3. 悋
                                          悋PictureBox        4. 悋 惘悸 惆 攵

                                                               悋
盒潮                              悋                            

                攵       惆悋   悋                       惆                惆Button 悋                          攵               攵   悋

                         惘慍        悋            攵   悋            Pixels 悋                  攵        惘悸 悋       悋       攵

//Create New BitMap Image To Put Pixels In And Set Its Width And Height
Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
     悋              悋            惘悸 攵       悋           悋       悋                 悋PictureBox 慍 愀   惷 悋                         惘悸    愀 悋



                                 Pixels惘悸           悋                             惘慍 攵           悋悋              攵

//Fill BMP Image Pixels With Points On The Line
bmp.SetPixel(x, y, Color.Red);

                                 PictureBox 悋                   惘悸        悋       惘慍 攵        悋

//Show BMP Image In The PictureBox
Graphics g = pictureBox1.CreateGraphics();
g.DrawImage(bmp, new Point(0, 0));

         ***



                                                                   惆

                                                     Direct Line Algorithm

                                                             惘    惺悋            悋    惆 悋
Drag & Drop                攵

                                  惆Draw Line       惡             悋Button 悋   攵

                                        悋攵     悋       悋   悋        惆

      private void btnDraw_Click(object sender, EventArgs e)
      {
            //Create New BitMap Image To Put Pixels In And Set Its Width And Height
            Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);

//Start Algorithm
            // The   Two Points Vertices
            int x1   = int.Parse(txtX1.Text),
                x2   = int.Parse(txtX2.Text),
                y1   = int.Parse(txtY1.Text),
                y2   = int.Parse(txtY2.Text);

             //m >> Slope
             double m = (x2 - x1) / (y2 - y1);

             //b >> Intersection With Y
             double b = y1 - (m * x1);

             //Find All Points Between The Two Points
             for (int x = x1; x <= x2; x++)
             {
                //From Line Equation >> (y = m*x + b)
                int y = (int)(m * x + b);

                  //Fill BMP Image Pixels With Points On The Line
                  bmp.SetPixel(x, y, Color.Red);
            }
//End Algorithm

             //Show BMP Image In The PictureBox
             Graphics g = pictureBox1.CreateGraphics();
             g.DrawImage(bmp, new Point(0, 0));
         }


                                                         惘惡 悋  悋

More Related Content

Graphics

  • 1. 鏃荷 惘 悋 悋慍 悋 悋 悋 悋 悋 悋惠 惆 悋 惘 TextBoxes 悋 惘 悋 悋 惘慍 惠 悋 悋 悋 悋 悋 悋 慍悋 TextBoxes 悋 攵 悋 PictureBox 攵 悋 攵 悋 悋 惘慍 悋 惆 悋 悋 悋 悋 悋 Button 攵 悋 悋 惺 悋Form 悋 Design 惆 悋 悋 愀 攵 惆 悋 悋PictureBox 惘慍 悋 攵 攵 悋 Button悋 悋 悋 攵 悋Button 攵 惆悋 悋 惆悋 攵 悋 Button惆 攵 悋 惆 惆 攵 悋悋 悋 攵 悋 悋 惠攵 悋 悋 悋 慍悋 悋 悋 TextBoxes 惠悋 惆 悋 1. 攵 悋 惘慍 悋惆 2. 惘悸 惘慍 惆 攵 3. 悋 悋PictureBox 4. 悋 惘悸 惆 攵 悋
  • 2. 盒潮 悋 攵 惆悋 悋 惆 惆Button 悋 攵 攵 悋 惘慍 悋 攵 悋 Pixels 悋 攵 惘悸 悋 悋 攵 //Create New BitMap Image To Put Pixels In And Set Its Width And Height Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); 悋 悋 惘悸 攵 悋 悋 悋 悋PictureBox 慍 愀 惷 悋 惘悸 愀 悋 Pixels惘悸 悋 惘慍 攵 悋悋 攵 //Fill BMP Image Pixels With Points On The Line bmp.SetPixel(x, y, Color.Red); PictureBox 悋 惘悸 悋 惘慍 攵 悋 //Show BMP Image In The PictureBox Graphics g = pictureBox1.CreateGraphics(); g.DrawImage(bmp, new Point(0, 0)); *** 惆 Direct Line Algorithm 惘 惺悋 悋 惆 悋
  • 3. Drag & Drop 攵 惆Draw Line 惡 悋Button 悋 攵 悋攵 悋 悋 悋 惆 private void btnDraw_Click(object sender, EventArgs e) { //Create New BitMap Image To Put Pixels In And Set Its Width And Height Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); //Start Algorithm // The Two Points Vertices int x1 = int.Parse(txtX1.Text), x2 = int.Parse(txtX2.Text), y1 = int.Parse(txtY1.Text), y2 = int.Parse(txtY2.Text); //m >> Slope double m = (x2 - x1) / (y2 - y1); //b >> Intersection With Y double b = y1 - (m * x1); //Find All Points Between The Two Points for (int x = x1; x <= x2; x++) { //From Line Equation >> (y = m*x + b) int y = (int)(m * x + b); //Fill BMP Image Pixels With Points On The Line bmp.SetPixel(x, y, Color.Red); } //End Algorithm //Show BMP Image In The PictureBox Graphics g = pictureBox1.CreateGraphics(); g.DrawImage(bmp, new Point(0, 0)); } 惘惡 悋 悋