Пример #1
0
        // !MAIN! Generating Method -> through button2 ( Generate BTN)
        private void button2_Click(object sender, EventArgs e)
        {
            targerImg = new ImageProcessor.ImageFactory();
            try {
                if (targetpicture != null)
                {
                    targerImg.Load(targetpicture);
                }
                else
                {
                    targerImg.Load(previewbox.Image);
                }
            } catch (Exception ex) {
                MessageBox.Show("You have not loaded image! Please click 'Load Image' button", "Ops!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }


            string path = System.IO.Path.GetRandomFileName().ToString() + ".png";


            try
            {
                if (comboBox1.SelectedIndex >= 0)
                {
                    switch (comboBox1.SelectedIndex)
                    {
                    case 0:
                        targerImg.Filter(ImageProcessor.Imaging.Filters.Photo.MatrixFilters.BlackWhite);
                        Debug.WriteLine(comboBox1.SelectedText);
                        break;

                    case 1:
                        targerImg.Filter(ImageProcessor.Imaging.Filters.Photo.MatrixFilters.Comic);
                        break;

                    case 2:
                        targerImg.Filter(ImageProcessor.Imaging.Filters.Photo.MatrixFilters.Gotham);
                        break;

                    case 3:
                        targerImg.Filter(ImageProcessor.Imaging.Filters.Photo.MatrixFilters.GreyScale);
                        break;

                    case 4:
                        targerImg.Filter(ImageProcessor.Imaging.Filters.Photo.MatrixFilters.HiSatch);
                        break;

                    case 5:
                        targerImg.Filter(ImageProcessor.Imaging.Filters.Photo.MatrixFilters.Invert);
                        break;

                    case 6:
                        targerImg.Filter(ImageProcessor.Imaging.Filters.Photo.MatrixFilters.Lomograph);
                        break;

                    case 7:
                        targerImg.Filter(ImageProcessor.Imaging.Filters.Photo.MatrixFilters.LoSatch);
                        break;

                    case 8:
                        targerImg.Filter(ImageProcessor.Imaging.Filters.Photo.MatrixFilters.Polaroid);
                        break;

                    case 9:
                        targerImg.Filter(ImageProcessor.Imaging.Filters.Photo.MatrixFilters.Sepia);
                        break;
                    }
                }
                if (blur_cb.Checked == true)
                {
                    targerImg.GaussianBlur(10);
                }
                if (vignette_cb.Checked == true)
                {
                    if (colorDialog_Vignette.Color == null)
                    {
                        targerImg.Vignette(DEFAULT_VIGNETTE_COLOR);
                    }
                    else
                    {
                        targerImg.Vignette(colorDialog_Vignette.Color);
                    }
                }
                if (round_cb.Checked == true)
                {
                    targerImg.RoundedCorners(25);
                }
                if (richTextBox1.Text != "")
                {
                    using (ImageProcessor.Imaging.TextLayer Text = new ImageProcessor.Imaging.TextLayer())
                    {
                        Text.Text = richTextBox1.Text.ToString();
                        if (checkBox1.Checked == true)
                        {
                            Text.DropShadow = true;
                        }
                        else
                        {
                            Text.DropShadow = false;
                        }
                        Text.FontSize   = Convert.ToInt32(fontDialog1.Font.Size);
                        Text.FontColor  = colorDialog1.Color;
                        Text.FontFamily = fontDialog1.Font.FontFamily;


                        targerImg.Watermark(Text);
                    }
                }

                targerImg.Save(System.IO.Path.GetTempPath().ToString() + path);

                pictureBox1.Load(System.IO.Path.GetTempPath().ToString() + path);
            }
            catch (Exception ex)
            {
            }
        }