public void LoadBitmap(Bitmap bmp) { originalBmp = bmp; originalPhoto = Convertors.Bitmap2Photo(bmp); original.Image = originalBmp; original.Left = 0; original.Top = 0; original.ClientSize = originalBmp.Size; processed.Left = 0; processed.Top = original.Bottom; processed.Size = original.Size; filtersSelect.Left = original.Right + 10; filtersSelect.Top = 20; filtersSelect.Width = 200; filtersSelect.Height = 20; ClientSize = new Size(filtersSelect.Right + 20, processed.Bottom); apply.Left = ClientSize.Width - 120; apply.Top = ClientSize.Height - 50; apply.Width = 100; apply.Height = 40; FilterChanged(null, EventArgs.Empty); }
void Process(object sender, EventArgs empty) { var timer = new Stopwatch(); timer.Start(); var data = parametersControls.Select(z => (double)z.Value).ToArray(); var filter = (IFilter)filtersSelect.SelectedItem; Photo result = null; result = filter.Process(originalPhoto, data); var resultBmp = Convertors.Photo2Bitmap(result); if (resultBmp.Width > originalBmp.Width || resultBmp.Height > originalBmp.Height) { float k = Math.Min((float)originalBmp.Width / resultBmp.Width, (float)originalBmp.Height / resultBmp.Height); var newBmp = new Bitmap((int)(resultBmp.Width * k), (int)(resultBmp.Height * k)); using (var g = Graphics.FromImage(newBmp)) { g.DrawImage(resultBmp, new Rectangle(0, 0, newBmp.Width, newBmp.Height), new Rectangle(0, 0, resultBmp.Width, resultBmp.Height), GraphicsUnit.Pixel); } resultBmp = newBmp; } processed.Image = resultBmp; timer.Stop(); MessageBox.Show(timer.ElapsedMilliseconds.ToString()); }