Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        private void Reset(object sender, EventArgs e)
        {
            reset.Enabled = false;
            originalPhoto = Convertors.Bitmap2Photo(bitmap);

            filtersSelect.SelectedIndex = 0;

            FilterChanged(null, EventArgs.Empty);
            Process(null, EventArgs.Empty);
        }
Ejemplo n.º 3
0
        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  = 250;
            filtersSelect.Height = 20;
            filtersSelect.Font   = defaultFont1;

            ClientSize = new Size(filtersSelect.Right + 20, processed.Bottom);

            apply.Width  = 150;
            apply.Height = 50;
            apply.Left   = ClientSize.Width - apply.Width - 20;
            apply.Top    = ClientSize.Height - apply.Height - 10;
            apply.Font   = new Font("Arial", 14);

            reset.Width  = 150;
            reset.Height = 50;
            reset.Left   = ClientSize.Width - reset.Width - 20;
            reset.Top    = ClientSize.Height - apply.Height - reset.Height - 20;
            reset.Font   = new Font("Arial", 14);

            FilterChanged(null, EventArgs.Empty);
        }
Ejemplo n.º 4
0
        void Process(object sender, EventArgs empty)
        {
            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;
            reset.Enabled   = true;
            originalPhoto   = Convertors.Bitmap2Photo(resultBmp);
        }