/// <summary> /// Displays the specified image in a window and waits the user to create a rectangle by drawing. /// <para>Press and hold shift + mouse (track-pad) to translate and zoom an image.</para> /// </summary> /// <param name="image">Image to display.</param> /// <param name="windowTitle">Window title (ID).</param> /// <param name="scaleForm">True to adjust form to the image size, false otherwise.</param> /// <returns>Drawn rectangle.</returns> public static RectangleF GetRectangle(this Bgr <byte>[,] image, string windowTitle = "Draw rectangle (close when finished)", bool scaleForm = false) { var rect = FormCollection.CreateAndShowDialog(() => { var f = new DrawingRectangleForm(windowTitle); f.ScaleForm = scaleForm; f.SetImage(image); return(f); }, f => f.Rectangle); return(rect); }
/// <summary> /// Displays the specified image in a window and waits the user to create a rectangle by drawing. /// <para>Press and hold shift + mouse (track-pad) to translate and zoom an image.</para> /// </summary> /// <param name="image">Image to display.</param> /// <param name="windowTitle">Window title (ID).</param> /// <param name="scaleForm">True to adjust form to the image size, false otherwise.</param> /// <returns>Drawn rectangle.</returns> public static RectangleF GetRectangle(this Bgr<byte>[,] image, string windowTitle = "Draw rectangle (close when finished)", bool scaleForm = false) { var rect = FormCollection.CreateAndShowDialog(() => { var f = new DrawingRectangleForm(windowTitle); f.ScaleForm = scaleForm; f.SetImage(image); return f; }, f => f.Rectangle); return rect; }