Exemplo n.º 1
0
 public MainInterface()
 {
     InitializeComponent();
     _fractalG = new FractalGenerator(pictureBoxFractal.Size);
     pictureBoxGraphics = pictureBoxFractal.CreateGraphics();
     foreach(FractalType ft in Enum.GetValues(typeof(FractalType))) {
         comboFractType.Items.Add(ft);
     }
     comboFractType.SelectedIndex = 0;
     DataGenerationDone += DataGeneratedOk;
     _viewPort = new RectangleF(-1, -1, 2, 2);
     regenerate();
 }
Exemplo n.º 2
0
        private void btExport_Click(object sender, EventArgs e)
        {
            int width, height;
            SaveFileDialog sfd;
            Bitmap im;
            FractalGenerator fractalG;
            String fileName;

            try
            {
                width = int.Parse(tbWidth.Text);
                height = int.Parse(tbHeight.Text);
                sfd = new SaveFileDialog();
                sfd.DefaultExt = ".png";
                sfd.AddExtension = true;
                sfd.CheckPathExists = true;
                sfd.Filter = "Image png (*.png)|*.png|Image jpeg (*.jpg)|*.jpg";
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    fileName = sfd.FileName;
                    // Forced AA * 4 (size *2 on with, Height)
                    _fractalP.width = width * 2;
                    _fractalP.height = height * 2;

                    _fractalP.viewPort.X = float.Parse(txtViewPosX.Text);
                    _fractalP.viewPort.Y = float.Parse(txtViewPosY.Text);
                    _fractalP.viewPort.Width = float.Parse(txtViewWidth.Text);
                    _fractalP.viewPort.Height = float.Parse(txtViewHeight.Text);

                    _fractalP.highQuality = true;

                    this.Enabled = false;
                    this.tbHeight.Enabled = false;
                    this.tbWidth.Enabled = false;
                    fractalG = new FractalGenerator(width, height);
                    fractalG.generate(_fractalP, null);
                    fractalG.generateImage(_renderP, null);
                    im = fractalG.Image;
                    this.Enabled = true;
                    // 2x High quality downscaling

                    Bitmap tmpImage = new Bitmap(width, height, im.PixelFormat);
                    Graphics handle = Graphics.FromImage(tmpImage);
                    handle.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    handle.DrawImage(fractalG.Image, 0, 0, width, height);
                    // Save the image
                    tmpImage.Save(fileName);

                    this.Close();
                }
            }
            catch (FormatException)
            {
                MessageBox.Show("Invalid Numerical Value", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (ArgumentException exc)
            {
                MessageBox.Show("Invalid Image name : " + exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            // Add others
        }