Ejemplo n.º 1
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            if (impl == Implement.ASEMBLER)
            {
                stopwatch.Start();
                IntPtr a0 = Marshal.UnsafeAddrOfPinnedArrayElement(myBitmap.PixelArray, 0);
                switch (action)
                {
                case Action.BMP_GREYSCALE:
                    MyBitmapEditor.UnsafeNativeMethods.GreyASM(a0, myBitmap.BitmapInfo.SizeX, myBitmap.BitmapInfo.SizeY);
                    myBitmap.finalizeAssemblerFunc();
                    break;

                case Action.BMP_INVERSE:
                    MyBitmapEditor.UnsafeNativeMethods.InverseASM(a0, myBitmap.BitmapInfo.SizeX, myBitmap.BitmapInfo.SizeY);
                    myBitmap.finalizeAssemblerFunc();
                    break;

                case Action.BMP__SHARPEN:
                    byte[,] resultArray = myBitmap.convertArray(myBitmap.ByteArray, myBitmap.BitmapInfo.SizeX, myBitmap.BitmapInfo.SizeY);
                    IntPtr a1 = Marshal.UnsafeAddrOfPinnedArrayElement(resultArray, 0);
                    MyBitmapEditor.UnsafeNativeMethods.SharpASM(a0, a1, myBitmap.BitmapInfo.SizeX, myBitmap.BitmapInfo.SizeY);
                    myBitmap.finalizeAssemblerFuncSharp(resultArray);
                    break;
                }
                stopwatch.Stop();
            }

            else if (impl == Implement.C__SHARP)
            {
                stopwatch.Start();
                switch (action)
                {
                case Action.BMP_GREYSCALE:
                    bmpManager.BitMapEditor.grayScale(myBitmap);
                    break;

                case Action.BMP_INVERSE:
                    bmpManager.BitMapEditor.inverseBitmap(myBitmap);
                    break;

                case Action.BMP__SHARPEN:
                    bmpManager.BitMapEditor.sharpenBitmap(myBitmap);
                    break;
                }
                stopwatch.Stop();
            }
        }