Beispiel #1
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (saveFileDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            Rgb.RgbToBitmapQ(this.out_arr).Save(saveFileDialog1.FileName);
        }
        public void Draw(Bitmap img)
        {
            new Thread(() => Application.Run(new IndicatorForm(img.Width, img.Height))).Start();
            Thread.Sleep(5000);

            Metrics metrics = new Metrics("OutlineSel");

            var kernel = new double[, ]
            {
                { 0.1, 0.1, 0.1 },
                { 0.1, 0.1, 0.1 },
                { 0.1, 0.1, 0.1 }
            };

            img = Rgb.RgbToBitmapQ(Rgb.Convolution(Rgb.BitmapToByteRgbQ(img), kernel));

            List <List <bool> > img_c = new List <List <bool> >();

            for (int i = 0; i < img.Width; i++)
            {
                img_c.Add(new List <bool>());
                for (int j = 0; j < img.Height; j++)
                {
                    img_c[i].Add(false);
                }
            }

            for (int x = 0; x < img.Width; x++)
            {
                for (int y = 0; y < img.Height; y++)
                {
                    Color clr = img.GetPixel(x, y);
                    if (((clr.R + clr.G + clr.B) / 3) < Settings.Default.sensitivity)
                    {
                        img_c[x][y] = true;
                        metrics.TotalPixels++;
                    }
                }
            }

            Point st_pos = Cursor.Position;

            OptimizedDrafter.DrawArray(img_c, st_pos, 1, metrics);

            metrics.EndTime = DateTime.Now;
            if (Settings.Default.metrics)
            {
                Application.Run(new MetricsForm(metrics));
            }
        }
Beispiel #3
0
        private void draw_img()
        {
            switch (Settings.Default.draft_mode)
            {
            case 7:
                double[,] kernel = new double[, ]
                {
                    { 0.1, 0.1, 0.1 },
                    { 0.1, 0.1, 0.1 },
                    { 0.1, 0.1, 0.1 }
                };
                in_arr = Rgb.Convolution(in_arr, kernel);
                break;
            }

            for (int y = 0; y < this.image.Height; y++)
            {
                for (int x = 0; x < this.image.Width; x++)
                {
                    float br = (in_arr[0, y, x] + in_arr[1, y, x] + in_arr[2, y, x]) / 3;
                    if (br < Settings.Default.sensitivity)
                    {
                        out_arr[0, y, x] = 0;
                        out_arr[1, y, x] = 0;
                        out_arr[2, y, x] = 0;
                    }
                    else
                    {
                        out_arr[0, y, x] = 255;
                        out_arr[1, y, x] = 255;
                        out_arr[2, y, x] = 255;
                    }
                }
            }
            this.pictureBox1.Image = Rgb.RgbToBitmapQ(out_arr);
        }