예제 #1
0
        // Adjust the Brightness (and eventually Contrast)
        private void MenuTransparency(object sender, EventArgs e)
        {
            if (picBoxMain.Image != null)
            {
                // The byte value is necessary for the image adjustments
                byte amount = 0;
                // Creating the Form that will be the dialog box
                using (Brightness dlgBright = new Brightness())
                {
                    // Result is saved before check, so the result can be checked in more than one bool statement
                    DialogResult dlgResult = dlgBright.ShowDialog();

                    if (dlgResult == DialogResult.OK)
                    {
                        amount = dlgBright.getAmount();
                        listLoadedImg[curImgIndex].CreatePreviousVer();

                        // tmp created for readability, with transparency is applied separately. The main picBox image is also updated here.
                        Bitmap tmp = ApplyTransparency(listLoadedImg[curImgIndex].GetBitmap("c"), amount);
                        listLoadedImg[curImgIndex].UpdateBitmap("c", tmp);
                        picBoxMain.Image = listLoadedImg[curImgIndex].GetBitmap("c");
                    }
                    else if (dlgResult == DialogResult.Cancel)
                    {
                        // Nothing
                    }
                    else
                        MessageBox.Show("Error");
                }
            }
        }
예제 #2
0
        private void menuBatchTransparency_Click(object sender, EventArgs e)
        {
            if (picBoxMain.Image != null)
            {
                using (Brightness dlgTrans = new Brightness())
                {
                    if (dlgTrans.ShowDialog() == DialogResult.OK)
                    {
                        byte x = dlgTrans.getAmount();
                        MessageBox.Show(x.ToString());

                        foreach (LoadedImage img in listLoadedImg)
                        {
                            listLoadedImg[curImgIndex].CreatePreviousVer();
                            img.UpdateBitmap("c", ApplyTransparency(img.GetBitmap("c"), x));
                        }
                        UpdatePicbox(listLoadedImg[curImgIndex]);
                        BatchFileProcess();
                    }
                }
            }
            else
            {
                MessageBox.Show("You must first load an image.");
            }
        }