Ejemplo n.º 1
0
        private void ShowBitmap(TIS.Imaging.OverlayBitmap ob)
        {
            try
            {
                // path to the overlay image file
                string imgPath = Environment.ExpandEnvironmentVariables("%IC34PATH%") + @"\samples\C# 2010\Creating an Overlay\Creating an Overlay\hardware.bmp";

                // Load the sample bitmap from the project file's directory.
                Image bmp = Bitmap.FromFile(imgPath);

                // Calculate the column to display the bitmap in the
                // upper right corner of Imaging Control.
                int col = icImagingControl1.ImageWidth - 5 - bmp.Width;

                // Retrieve the Graphics object of the OverlayBitmap.
                Graphics g = ob.GetGraphics();

                // Draw the image
                g.DrawImage(bmp, col, 5);

                // Release the Graphics after drawing is finished.
                ob.ReleaseGraphics(g);
            }
            catch (Exception Ex)
            {
                MessageBox.Show("File not found: " + Ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void IcCam_OverlayUpdate(object sender, TIS.Imaging.ICImagingControl.OverlayUpdateEventArgs e)
        {
            //// IcCam.LiveStop();

            TIS.Imaging.OverlayBitmap ob  = IcCam.OverlayBitmapAtPath[PathPositions.Display];
            GonImageProcessing        gip = new GonImageProcessing(GetLiveImage());

            SetOverlay();
            //ob.DrawFrameRect(Color.Blue, i, i, i+ 20, i + 20);
            //i++;
            gip.CalcCross();
            ob.DrawFrameRect(Color.Blue, 0, 0, 40, 40);
            ob.DrawFrameRect(Color.Blue, (int)gip.X, (int)gip.Y, (int)gip.X + (int)gip.Width, (int)gip.Y + (int)gip.Height);
            // //IcCam.LiveStart();
        }
Ejemplo n.º 3
0
        private void SetupOverlay(TIS.Imaging.OverlayBitmap ob)
        {
            // Enable the overlay bitmap for drawing.
            ob.Enable = true;

            // Set magenta as dropout color.
            ob.DropOutColor = Color.Magenta;

            // Fill the overlay bitmap with the dropout color.
            ob.Fill(ob.DropOutColor);

            // Print text in red.
            ob.FontTransparent = true;
            ob.DrawText(Color.Gray, 10, 10, "Graph Measurement");
        }
Ejemplo n.º 4
0
 private void hide_Click(object sender, EventArgs e)
 {
     if (CoordinatesystemFlag == true)
     {
         TIS.Imaging.OverlayBitmap ob = icImagingControl1.OverlayBitmapAtPath[TIS.Imaging.PathPositions.Device];
         ob.DrawSolidRect(ob.DropOutColor, 0, 0,
                          1031, 774);
         CoordinatesystemFlag = false;
         hide.Text            = "Show the scale";
     }
     else
     {
         CoordinatesystemFlag = true;
         hide.Text            = "Hide the scale";
     }
 }
Ejemplo n.º 5
0
        private void SetOverlay()
        {
            IcCam.LiveCaptureContinuous = true;
            TIS.Imaging.OverlayBitmap ob = IcCam.OverlayBitmapAtPath[PathPositions.Display];
            // Enable the overlay bitmap for drawing.
            ob.Enable = true;

            // Set magenta as dropout color.
            ob.DropOutColor = Color.Magenta;

            // Fill the overlay bitmap with the dropout color.
            ob.Fill(ob.DropOutColor);
            ob.FontTransparent = true;
            ob.DrawText(Color.Red, 10, 10, "Copyright trademark incorporated all rights reserved");
            ob.DrawFrameRect(Color.Red, IcCam.Width / 2 - 40, IcCam.Height / 2 - 40, IcCam.Width / 2 + 40, IcCam.Height / 2 + 40);
            ob.DrawLine(Color.Red, IcCam.Width / 2, IcCam.Height / 2 - 40, IcCam.Width / 2, 0);
            ob.DrawLine(Color.Red, IcCam.Width / 2, IcCam.Height / 2 + 40, IcCam.Width / 2, IcCam.Height);

            ob.DrawLine(Color.Red, 0, IcCam.Height / 2, IcCam.Width / 2 - 40, IcCam.Height / 2);
            ob.DrawLine(Color.Red, IcCam.Width / 2 + 40, IcCam.Height / 2, IcCam.Width, IcCam.Height / 2);
            ob.DrawLine(Color.Red, IcCam.Width / 2 - 10, IcCam.Height / 2, IcCam.Width / 2 + 10, IcCam.Height / 2);
            ob.DrawLine(Color.Red, IcCam.Width / 2, IcCam.Height / 2 + 10, IcCam.Width / 2, IcCam.Height / 2 - 10);
        }
Ejemplo n.º 6
0
        private void DrawCoordinatesystem(TIS.Imaging.OverlayBitmap ob)
        {
            // Calculate the center of the video image.
            int Col = icImagingControl1.ImageWidth / 2;
            int Row = icImagingControl1.ImageHeight / 2;

            Font OldFont = ob.Font;

            ob.Font = new Font("Arial", 8);

            ob.DrawLine(Color.Gray, Col, 0, Col, icImagingControl1.ImageHeight);
            ob.DrawLine(Color.Gray, 0, Row, icImagingControl1.ImageWidth, Row);

            for (int i = 0; i < Row; i += 20)
            {
                ob.DrawLine(Color.Gray, Col - 5, Row - i, Col + 5, Row - i);
                ob.DrawLine(Color.Gray, Col - 5, Row + i, Col + 5, Row + i);
                if (i > 0)
                {
                    ob.DrawText(Color.Gray, Col + 10, Row - i - 7, string.Format("{0}", i / 10));
                    ob.DrawText(Color.Gray, Col + 10, Row + i - 7, string.Format("{0}", -i / 10));
                }
            }

            for (int i = 0; i < Col; i += 20)
            {
                ob.DrawLine(Color.Gray, Col - i, Row - 5, Col - i, Row + 5);
                ob.DrawLine(Color.Gray, Col + i, Row - 5, Col + i, Row + 5);
                if (i > 0)
                {
                    ob.DrawText(Color.Gray, Col + i - 5, Row - 17, string.Format("{0}", i / 10));
                    ob.DrawText(Color.Gray, Col - i - 10, Row - 17, string.Format("{0}", -i / 10));
                }
            }

            ob.Font = OldFont;
        }
Ejemplo n.º 7
0
        private void icImagingControl1_OverlayUpdate(object sender, TIS.Imaging.ICImagingControl.OverlayUpdateEventArgs e)
        {
            TIS.Imaging.OverlayBitmap ob = e.overlay;

            int lineIndex = m_sink.FrameCount % 25;

            if (lineIndex == 0)
            {
                ob.DrawSolidRect(ob.DropOutColor, 10, icImagingControl1.ImageHeight - 70, 62,
                                 icImagingControl1.ImageHeight - 9);
            }

            /*ob.DrawLine(Color.Black, lineIndex * 2 + 10,
             *                              icImagingControl1.ImageHeight - 10,
             *                              lineIndex * 2 + 10,
             *                              icImagingControl1.ImageHeight - 10 - lineIndex);*/

            // Print the current frame number:
            // Set the background color to the current dropout color
            // and make the font opaque.
            ob.FontBackColor   = ob.DropOutColor;
            ob.FontTransparent = false;

            // Save the current font.
            Font OldFont = ob.Font;

            // Draw the text.
            ob.Font = new Font("Arial", 8);
            ob.DrawSolidRect(ob.DropOutColor, 0, 0, 1031, 774);

            if (CoordinatesystemFlag == true)
            {
                //DrawCoordinatesystem(icImagingControl1.OverlayBitmapAtPath[PathPositions.Device]);
            }

            ob.DrawText(Color.Black, textBox1.Location.X, textBox1.Location.Y, textBox1.Text);
            ob.DrawText(Color.Black, textBox2.Location.X, textBox2.Location.Y, textBox2.Text);
            ob.DrawText(Color.Black, textBox3.Location.X, textBox3.Location.Y, textBox3.Text);
            ob.DrawText(Color.Black, textBox4.Location.X, textBox4.Location.Y, textBox4.Text);
            ob.DrawText(Color.Black, textBox5.Location.X, textBox5.Location.Y, textBox5.Text);

            if ((textBox1.Text == "") || (textBox2.Text == ""))
            {
                ob.DrawSolidRect(ob.DropOutColor, 0, 0, 1031, 774);
                if (CoordinatesystemFlag == true)
                {
                    //DrawCoordinatesystem(icImagingControl1.OverlayBitmapAtPath[PathPositions.Device]);
                }
            }
            else
            {
                if (cycle.Checked == true)
                {
                    ob.DrawFrameEllipse(Color.Black, textBox1.Location.X, textBox1.Location.Y, textBox2.Location.X, textBox2.Location.Y);
                    ob.DrawFrameRect(Color.Black, textBox1.Location.X, textBox1.Location.Y, textBox2.Location.X, textBox2.Location.Y);
                }
                else
                {
                    ob.DrawLine(Color.Black, textBox1.Location.X, textBox1.Location.Y, textBox2.Location.X, textBox2.Location.Y);
                    if (textBox3.Text != "")
                    {
                        if (segment.Checked == true)
                        {
                        }
                        else if (triangle.Checked == true)
                        {
                            ob.DrawLine(Color.Black, textBox1.Location.X, textBox1.Location.Y, textBox3.Location.X, textBox3.Location.Y);
                            ob.DrawLine(Color.Black, textBox2.Location.X, textBox2.Location.Y, textBox3.Location.X, textBox3.Location.Y);
                        }
                        else if (quadrilateral.Checked == true && textBox4.Text != "")
                        {
                            ob.DrawLine(Color.Black, textBox1.Location.X, textBox1.Location.Y, textBox4.Location.X, textBox4.Location.Y);
                            ob.DrawLine(Color.Black, textBox2.Location.X, textBox2.Location.Y, textBox3.Location.X, textBox3.Location.Y);
                            ob.DrawLine(Color.Black, textBox3.Location.X, textBox3.Location.Y, textBox4.Location.X, textBox4.Location.Y);
                        }
                    }
                }
            }

            // Restore the previously used font.
            ob.Font = OldFont;
        }