Exemplo n.º 1
0
        private void button8_Click_1(object sender, EventArgs e)
        {
            var bmp = new Bitmap(img);

            using (var bitmapReader = new BitmapPixelDataReader(bmp))
            {
                int       work_to_do = bitmapReader.data.Length / thread;
                Thread[]  threads    = new Thread[thread];
                Stopwatch watch      = new Stopwatch();
                watch.Start();
                for (int i = 0; i < thread; i++)
                {
                    var start = i * work_to_do;
                    var stop  = (i + 1) * work_to_do;
                    threads[i] = new Thread(() => ASM.MyProc3(bitmapReader.data, work_to_do, start));
                    threads[i].Start();
                }

                for (int i = 0; i < thread; i++)
                {
                    threads[i].Join();
                }
                watch.Stop();
                textBox1.Text = watch.Elapsed.TotalMilliseconds.ToString();

                //  ASM.MyProc3(bitmapReader.data, bitmapReader.data.Length, 0);
            }
            bmp.Save("out.jpg", ImageFormat.Jpeg);
        }
Exemplo n.º 2
0
        private void button5_Click(object sender, EventArgs e)
        {
            var bmp = new Bitmap(img);

            // using uzywamy do unmanaged resource po wyjsciu z using skasujemy zasób wywołanie dispose z automatu

            using (var bitmapReader = new BitmapPixelDataReader(bmp))
            {
                int       work_to_do = bitmapReader.data.Length / thread;
                Thread[]  threads    = new Thread[thread];
                Stopwatch watch      = new Stopwatch();
                watch.Start();
                for (int i = 0; i < thread; i++)
                {
                    var start = i * work_to_do;
                    var stop  = (i + 1) * work_to_do;
                    threads[i] = new Thread(() => b_w(bitmapReader.data, start, stop));
                    threads[i].Start();
                }

                for (int i = 0; i < thread; i++)
                {
                    threads[i].Join();
                }
                watch.Stop();
                textBox1.Text = watch.Elapsed.TotalMilliseconds.ToString();
            }
            bmp.Save("out.jpg", ImageFormat.Jpeg);
        }
Exemplo n.º 3
0
        private void button6_Click(object sender, EventArgs e)
        {
            var bmp = new Bitmap(img);

            using (var bitmapReader = new BitmapPixelDataReader(bmp))
            {
                rozmycie(bitmapReader.data, bmp.Height, bmp.Width, thread);
            }
            bmp.Save("out.jpg", ImageFormat.Jpeg);
        }