示例#1
0
文件: Form1.cs 项目: MerywmElf/lab-1
        private void закрытиеToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String[] filters = new String[2];
            filters[0] = "DilationFilter";
            filters[1] = "ErosionFilter";
            ProcessingTask task = new ProcessingTask(image, filters);

            backgroundWorker1.RunWorkerAsync(task);
        }
示例#2
0
文件: Form1.cs 项目: MerywmElf/lab-1
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            Bitmap newImage;

            if (e.Argument is ProcessingTask)
            {
                ProcessingTask task = (ProcessingTask)e.Argument;
                newImage = task.image;
                for (int i = 0; i < task.filters.Count(); i++)
                {
                    Filters filter = task.createFilter(task.filters[i]);
                    newImage = filter.processImage(newImage, backgroundWorker1);
                }
            }
            else
            {
                newImage = ((Filters)e.Argument).processImage(image, backgroundWorker1);
            }

            if (backgroundWorker1.CancellationPending != true)
            {
                image = newImage;
            }
        }