VisionPro_CogRecordDisplay_ interception of the picture area, returned the interception pictures

private void Form1_Load(object sender, EventArgs e)
        {
            cogDisplayStatusBarV21.Display = cogRecordDisplay1;
            cogToolBlock1 = (CogToolBlock)CogSerializer.LoadObjectFromFile(@"C:\Users\20857\Desktop\TouchBar现场\测试程序\PixelMapToolBlock.vpp");
            cogToolBlock1.Run();
            cogRecordDisplay1.Record = cogToolBlock1.CreateLastRunRecord();
            cogRecordDisplay1.Image = ((CogPixelMapTool)cogToolBlock1.Tools["CogPixelMapTool1"]).OutputImage;
            
            Bitmap bitmap= (Bitmap)cogRecordDisplay1.CreateContentBitmap(CogDisplayContentBitmapConstants.Image, null, 0);
            Point point = new Point(500, 880);
            cutImage (bitmap, point, 1500, 400) .Save (@ "C: \ Users \ 20857 \ Desktop \ TouchBar field \ Test Procedure \ 1.bmp");
        }

        /// <Summary>
        /// taken picture region, returns the image taken
        /// </ Summary>
        /// <param name = "srcImage"> </ param>
        /// <param name = "POS"> </ param>
        /// <param name = " cutWidth "> </ param>
        /// <param name =" cutHeight "> </ param>
        /// <Returns> </ Returns>
        Private cutImage Image (Image srcImage, POS Point, cutWidth int, int cutHeight)
        {
            Image cutedImage = null;
            // initialize a bitmap object, after storing the image taken
            Bitmap bmpDest = new Bitmap (cutWidth, cutHeight);
            G = Graphics.FromImage Graphics (bmpDest);

            // define a rectangle, the left vertex position to be taken in the image to be taken, taken image area and the size of the
            Rectangle rectSource = new Rectangle (pos.X, pos.Y, cutWidth , cutHeight);


            // rectangle defined, should be taken to position the image area drawing bitmap size and initialized
            // rectDest described, will be taken area, beginning from the left vertex bitmap drawing, the original size of the drawing area taken
            = new new rectDest the Rectangle the Rectangle (0, 0, cutWidth, cutHeight);

            // the first parameter is the object you want to load the image taken, and the second and third parameters are as defined earlier taken image rendering process and related attributes, the fourth attribute property value measurement unit that can be used
            g.drawImage (srcImage, rectDest, rectSource, GraphicsUnit.Pixel);
            // displaying the intercepted image on the GUI
            cutedImage = (image) bmpDest;
            G. the Dispose ();
            return cutedImage;
        }

Guess you like

Origin www.cnblogs.com/forblueskies/p/11441227.html