Ejemplo n.º 1
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    Bitmap imageOfUser = (Bitmap)Bitmap.FromFile(openFileDialog.FileName);

                    if ((imageOfUser.PixelFormat == System.Drawing.Imaging.PixelFormat.Format16bppGrayScale) || (Bitmap.GetPixelFormatSize(imageOfUser.PixelFormat) > 32))
                    {
                        MessageBox.Show("Sorry ;( Demo App support only color images !");

                        imageOfUser.Dispose();
                        imageOfUser = null;
                    }
                    else
                    {
                        if (imageOfUser.PixelFormat != System.Drawing.Imaging.PixelFormat.Format24bppRgb)
                        {
                            Bitmap temp = AForge.Imaging.Image.Clone(imageOfUser, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                            imageOfUser.Dispose();
                            imageOfUser = null;
                        }
                    }

                    ClearCurrentImage();
                    pictureBox1.Image = imageOfUser;

                    image = new ImageWithChanges(imageOfUser);
                    pictureBox1.Size = image.SourceImage.Size;
                    painter = new Painter(richTextBox1.BackColor, pictureBox1, trackBar3.Value);
                    painter.setContext(image.Context);

                    LockUnloclActionWithImage();
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.ToString());
            }
        }
Ejemplo n.º 2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     painter = new Painter();
 }