void UpdateCapture(Bitmap Image) { if (Image == null) { if (PreviewScreen.Image != null) { PreviewScreen.Image.Dispose(); PreviewScreen.Image = null; } return; } int height = Image.Height; int width = Image.Width; if (SettingOptionsWindow.Visible) { height -= (SettingOptionsWindow.CroppingBottom + SettingOptionsWindow.CroppingTop); width -= (SettingOptionsWindow.CroppingLeft + SettingOptionsWindow.CroppingRight); } else { height -= (CroppingBottom + CroppingTop); width -= (CroppingLeft + CroppingRight); } if (width > 0 && height > 0) { if (PreviewScreen.Image != null) { PreviewScreen.Image.Dispose(); } try { if (SettingOptionsWindow.Visible) { PreviewScreen.Image = Image.Clone(new Rectangle(SettingOptionsWindow.CroppingLeft, SettingOptionsWindow.CroppingTop, width, height), Image.PixelFormat); } else { PreviewScreen.Image = Image.Clone(new Rectangle(CroppingLeft, CroppingTop, width, height), Image.PixelFormat); } } catch { return; } int MenuThickness = ExternalAPI.GetSystemMetrics(15); if (SettingOptionsWindow.Visible) { if (SettingOptionsWindow.ResizeOutput) { this.SetClientSizeCore(SettingOptionsWindow.ResizeOutputWidth, SettingOptionsWindow.ResizeOutputHeight + MenuThickness); } else { this.SetClientSizeCore(width, height + MenuThickness); } } else { if (ResizeOutput) { this.SetClientSizeCore(ResizeOutputWidth, ResizeOutputHeight + MenuThickness); } else { this.SetClientSizeCore(width, height + MenuThickness); } } SettingOptionsWindow.WindowHeight = height; SettingOptionsWindow.WindowWidth = width; } Image.Dispose(); }