private void buttonConfirm_Click(object sender, EventArgs e) { if (cropPercent.Left >= cropPercent.Right || cropPercent.Top >= cropPercent.Bottom) { MessageBox.Show("You messed up your crop! Please try again.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); cropPercent = new RectangleF(0.25f, 0.25f, 0.5f, 0.5f); return; } float tolerance = 0.1f; //Account for float inprecision if (cropPercent.Left < 0 - tolerance || cropPercent.Top < 0 - tolerance || cropPercent.Right > 1 + tolerance || cropPercent.Bottom > 1 + tolerance) { MessageBox.Show("Your crop is outside the valid range! Please try again.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); cropPercent = new RectangleF(0.25f, 0.25f, 0.5f, 0.5f); return; } cropPercent.X = Math.Max(0, cropPercent.X); cropPercent.Y = Math.Max(0, cropPercent.Y); if (cropPercent.Right > 1) { cropPercent.Width = 1 - cropPercent.X; } if (cropPercent.Bottom > 1) { cropPercent.Height = 1 - cropPercent.Y; } int width, height; if ((Owner as MainForm).SarCompensate) { width = (Owner as MainForm).SarWidth; height = (Owner as MainForm).SarHeight; } else { FFMSSharp.Frame frame = Program.VideoSource.GetFrame(previewFrame.Frame); width = frame.EncodedResolution.Width; height = frame.EncodedResolution.Height; } GeneratedFilter = new CropFilter( (int)(width * cropPercent.Left), (int)(height * cropPercent.Top), -(int)(width - width * cropPercent.Right), -(int)(height - height * cropPercent.Bottom) ); DialogResult = DialogResult.OK; Close(); }
public CropForm(CropFilter CropPixels = null) { InitializeComponent(); InputFilter = CropPixels; this.previewFrame.Picture.Paint += new System.Windows.Forms.PaintEventHandler(this.previewPicture_Paint); this.previewFrame.Picture.MouseDown += new System.Windows.Forms.MouseEventHandler(this.previewPicture_MouseDown); this.previewFrame.Picture.MouseEnter += new System.EventHandler(this.previewPicture_MouseEnter); this.previewFrame.Picture.MouseLeave += new System.EventHandler(this.previewPicture_MouseLeave); this.previewFrame.Picture.MouseMove += new System.Windows.Forms.MouseEventHandler(this.previewPicture_MouseMove); this.previewFrame.Picture.MouseUp += new System.Windows.Forms.MouseEventHandler(this.previewPicture_MouseUp); }
internal static void ResetFilters() { Caption = null; Crop = null; Deinterlace = null; Denoise = null; Dub = null; Levels = null; MultipleTrim = null; Overlay = null; Resize = null; Reverse = null; Subtitle = null; Trim = null; }
private void buttonConfirm_Click(object sender, EventArgs e) { if (cropPercent.Left >= cropPercent.Right || cropPercent.Top >= cropPercent.Bottom) { MessageBox.Show("You messed up your crop! Please try again.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); cropPercent = new RectangleF(0.25f, 0.25f, 0.5f, 0.5f); return; } float tolerance = 0.1f; //Account for float inprecision if (cropPercent.Left < 0 - tolerance || cropPercent.Top < 0 - tolerance || cropPercent.Right > 1 + tolerance || cropPercent.Bottom > 1 + tolerance) { MessageBox.Show("Your crop is outside the valid range! Please try again.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); cropPercent = new RectangleF(0.25f, 0.25f, 0.5f, 0.5f); return; } cropPercent.X = Math.Max(0, cropPercent.X); cropPercent.Y = Math.Max(0, cropPercent.Y); if (cropPercent.Right > 1) cropPercent.Width = 1 - cropPercent.X; if (cropPercent.Bottom > 1) cropPercent.Height = 1 - cropPercent.Y; int width, height; if ((Owner as MainForm).SarCompensate) { width = (Owner as MainForm).SarWidth; height = (Owner as MainForm).SarHeight; } else { FFMSSharp.Frame frame = Program.VideoSource.GetFrame(previewFrame.Frame); width = frame.EncodedResolution.Width; height = frame.EncodedResolution.Height; } GeneratedFilter = new CropFilter( (int)(width * cropPercent.Left), (int)(height * cropPercent.Top), -(int)(width - width * cropPercent.Right), -(int)(height - height * cropPercent.Bottom) ); DialogResult = DialogResult.OK; Close(); }