/// <summary> /// /// </summary> /// <returns></returns> public static Image <Bgr, byte> CropImageFromBitmap(bool _flag) { if (myGlobal.bitmapSnapShot == null) { return(null); } try { Image <Bgr, byte> _imageRef = null; RectangleInfo _rectInfo = ConvertRect(); Image <Bgr, byte> imageInput = new Image <Bgr, byte>(myGlobal.bitmapSnapShot); System.Drawing.Rectangle _rect = new System.Drawing.Rectangle((int)_rectInfo.rectLeft, (int)_rectInfo.rectTop, (int)_rectInfo.rectWidth, (int)_rectInfo.rectHeight); imageInput.ROI = _rect; _imageRef = imageInput.CopyBlank(); imageInput.CopyTo(_imageRef); imageInput.ROI = System.Drawing.Rectangle.Empty; //Image<Gray, byte> _imgGray = new Image<Gray, byte>(_imageRef.Width, _imageRef.Height); //myBase.ConvertImageFromBgrToGray(_imageRef, ref _imgGray); //return _imgGray; return(_imageRef); } catch { return(null); } }
//Constructor public TestInformation() { myRect = new RectangleInfo(); myImage = new ImageInfo <int>(); myImageViewer = new ImageInfo <double>(); scalewidth = 0; scaleheight = 0; windowtop = 0; windowleft = 0; windowwidth = 0; windowheight = 0; windowbackground = Brushes.Transparent; windowopacity = 1; statustest = "--"; elapsedtime = "Elapsed time: 00:00:00 "; retrytime = "0"; systemlog = ""; rectInfo = ""; macaddress = "--"; cropImageSize = "--"; pixelDeviation = "--"; coefficient = "--"; testtime = "--"; CameraIsOnline = false; }
/// <summary> /// /// </summary> /// <returns></returns> public static RectangleInfo ConvertRect() { RectangleInfo _rect = new RectangleInfo(); _rect.rectWidth = myGlobal.defaultsetting.rectwidth * myGlobal.defaultsetting.scalewidth; _rect.rectLeft = myGlobal.defaultsetting.rectleft * myGlobal.defaultsetting.scalewidth; _rect.rectHeight = myGlobal.defaultsetting.rectheight * myGlobal.defaultsetting.scaleheight; _rect.rectTop = myGlobal.defaultsetting.recttop * myGlobal.defaultsetting.scaleheight; return(_rect); }