Beispiel #1
0
 protected override void Apply()
 {
     if (rbFlipHorizontal.Checked)
     {
         this.image.Flip(RotateFlipType.RotateNoneFlipX);
     }
     else if (rbFlipVertical.Checked)
     {
         this.image.Flip(RotateFlipType.RotateNoneFlipY);
     }
     else if (rbRotate.Checked)
     {
         double       dx     = this.btnOrigin.Location.X - this.previewBox.Location.X - this.previewBox.Width / 2.0 + this.preview.Width / 2.0;
         double       dy     = this.btnOrigin.Location.Y - this.previewBox.Location.Y - this.previewBox.Height / 2.0 + this.preview.Height / 2.0;
         double       sx     = this.image.Width / this.preview.Width;
         double       sy     = this.image.Height / this.preview.Height;
         FilterRotate filter = new FilterRotate((double)this.udAngle.Value, new Point((int)(sx * dx), (int)(sy * dy)));
         filter.FillColor = btnFillcolor.BackColor;
         unsafe
         {
             this.image.Apply(filter.Name, filter.Border, new ImageIndirectFilter(filter.Filter));
         }
     }
     else if (rbCompound.Checked)
     {
         this.image.Flip((RotateFlipType)this.cbCompound.SelectedItem);
     }
     this.Close();
 }
Beispiel #2
0
        private void btn_Ok_Click(object sender, EventArgs e)
        {
            try
            {
                double angle = double.Parse(cb_Rotate.Text);
                switch (cb_methodCombo.SelectedIndex)
                {
                case 0:
                    filter = new RotateNearestNeighbor(angle);
                    break;

                case 1:
                    filter = new RotateBilinear(angle);
                    break;

                case 2:
                    filter = new RotateBicubic(angle);
                    break;
                }

                filter.FillColor = Color.FromArgb(
                    byte.Parse(tb_R.Text),
                    byte.Parse(tb_G.Text),
                    byte.Parse(tb_B.Text));
                filter.KeepSize = cb_KeepSize.Checked;
                frmImgProcess.imgProcess.ApplyFilter(filter);
            }
            catch (Exception)
            {
                MessageBox.Show(this, "Incorrect values are entered", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        private void udAngle_ValueChanged(object sender, System.EventArgs e)
        {
            OnOriginalBitmapChanged(this.image, null);
            int          dx     = this.btnOrigin.Location.X - this.previewBox.Location.X - this.previewBox.Width / 2;
            int          dy     = this.btnOrigin.Location.Y - this.previewBox.Location.Y - this.previewBox.Height / 2;
            FilterRotate filter = new FilterRotate((double)this.udAngle.Value, new Point(dx + this.preview.Width / 2, dy + this.preview.Height / 2));

            filter.FillColor = btnFillcolor.BackColor;
            unsafe
            {
                this.preview.Apply(filter.Name, filter.Border, new ImageIndirectFilter(filter.Filter));
            }
        }
        // On "Ok" button
        private void okButton_Click( object sender, System.EventArgs e )
        {
            try
            {
                // get rotation angle
                double angle = double.Parse( angleBox.Text );

                // create appropriate rotation filter
                switch ( methodCombo.SelectedIndex )
                {
                    case 0:
                        filter = new RotateNearestNeighbor( angle );
                        break;
                    case 1:
                        filter = new RotateBilinear( angle );
                        break;
                    case 2:
                        filter = new RotateBicubic( angle );
                        break;
                }

                // fill color
                filter.FillColor = Color.FromArgb(
                    byte.Parse( redBox.Text ),
                    byte.Parse( greenBox.Text ),
                    byte.Parse( blueBox.Text ) );

                // keep size
                filter.KeepSize = keepSizeCheck.Checked;

                // close dialog
                this.DialogResult = DialogResult.OK;
                this.Close( );
            }
            catch ( Exception )
            {
                MessageBox.Show( this, "Incorrect values are entered", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error );
            }
        }
                    case 0:
                        filter = new RotateNearestNeighbor( angle );
                        break;
                    case 1:
                        filter = new RotateBilinear( angle );
                        break;
                    case 2:
                        filter = new RotateBicubic( angle );
                        break;
                }

                // fill color
                filter.FillColor = Color.FromArgb(
                    byte.Parse( redBox.Text ),
                    byte.Parse( greenBox.Text ),
                    byte.Parse( blueBox.Text ) );

                // keep size
                filter.KeepSize = keepSizeCheck.Checked;

                // close dialog
                this.DialogResult = DialogResult.OK;
                this.Close( );
            }
            catch ( Exception )
            {
                MessageBox.Show( this, "Incorrect values are entered", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error );
            }
        }
    }
}