コード例 #1
0
        private void translationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            //copy Undo Image
            imgUndo = img.Copy();

            DoubleInputBox dib = new DoubleInputBox("X Translation:", "Y Translation:", "Translation", numberTextBox, numberTextBox);

            dib.ShowDialog();

            int dx = Convert.ToInt32(dib.textBox1.Text);
            int dy = Convert.ToInt32(dib.textBox2.Text);

            if (dib.DialogResult == DialogResult.OK)
            {
                ImageClass.Translation(img, img.Copy(), dx, dy);

                ImageViewer.Image = img.Bitmap;
                ImageViewer.Refresh(); // refresh image on the screen
            }

            Cursor = Cursors.Default; // normal cursor
        }
コード例 #2
0
        private void brightnessContrastToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }

            //copy Undo Image
            imgUndo = img.Copy();

            int            brilho;
            double         cont;
            DoubleInputBox dib = new DoubleInputBox("Brightness:", "Contrast:", "Brightness/Contrast", numberTextBox, decimalTextBox);

            dib.ShowDialog();

            do
            {
                if (dib.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
                brilho = Convert.ToInt32(dib.textBox1.Text);
                cont   = Convert.ToSingle(dib.textBox2.Text);
            } while (Math.Abs(brilho) > 255 && (cont < 0 || cont > 3));

            Cursor = Cursors.WaitCursor; // clock cursor

            if (dib.DialogResult == DialogResult.OK)
            {
                ImageClass.BrightContrast(img, brilho, cont);

                ImageViewer.Image = img.Bitmap;
                ImageViewer.Refresh(); // refresh image on the screen
            }

            Cursor = Cursors.Default; // normal cursor
        }