Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            IDrafter drafter;

            switch (Settings.Default.draft_mode)
            {
            case 0:
                drafter = new LineDrafter();
                break;

            case 1:
                drafter = new RandomDrafter();
                break;

            case 2:
                drafter = new OptimizedDrafter(1);
                break;

            case 3:
                drafter = new OptimizedDrafter(2);
                break;

            case 4:
                drafter = new OptimizedDrafter(3);
                break;

            case 5:
                drafter = new OptimizedDrafter(4);
                break;

            case 6:
                drafter = new SinDeformDrafter();
                break;

            case 7:
                drafter = new OutlineSelDrafter();
                break;

            case 8:
                drafter = new SinDrafter();
                break;

            case 9:
                drafter = new TanDrafter();
                break;

            default:
                drafter = new OptimizedDrafter(1);
                break;
            }
            DrawThread = new Thread(() => drafter.Draw(LoadedImage));
            DrawThread.Start();
        }
        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));
            }
        }