Exemplo n.º 1
0
 public static extern UserTopoUnstrctGeomStruct *UserTopoAppendUnstrctGeoms(
     UserTopoUnstrctGeomStruct *UdA,
     UserTopoUnstrctGeomStruct *UdB,
     double Eps,
     int MergePts,
     int **CloneMap,
     int **RealIDMap);
Exemplo n.º 2
0
 public static extern UserTopoUnstrctGeomStruct *UserTopoAddPoints(
     UserTopoUnstrctGeomStruct *Ud,
     UserTopoUnstrctGeomPtStruct *Pts,
     int NumPt,
     int MergePts,
     int **CloneMap,
     int **RealIDMap);
Exemplo n.º 3
0
 public static void Append(int** values, int numOriginalValues, int newValue)
 {
     int* newArray = (int*)Marshal.AllocCoTaskMem(sizeof(int) * (numOriginalValues + 1));
     new Span<int>(*values, numOriginalValues).CopyTo(new Span<int>(newArray, numOriginalValues));
     newArray[numOriginalValues] = newValue;
     *values = newArray;
 }
Exemplo n.º 4
0
 public static int** ReturnDuplicatePointers(int** values, int numValues)
 {
     int sizeInBytes = sizeof(int*) * numValues;
     int** newArray = (int**)Marshal.AllocCoTaskMem(sizeInBytes);
     new Span<byte>(values, sizeInBytes).CopyTo(new Span<byte>(newArray, sizeInBytes));
     return newArray;
 }
Exemplo n.º 5
0
        public static int[][] SimultaneousSameDivisor(double[] x, int n, double alpha, double epsilon)
        {
            int[][] result = new int[n + 1][];

            unsafe
            {
                fixed(double *arr = new double[n])
                {
                    for (int i = 0; i < n; i++)
                    {
                        arr[i] = x[i];
                    }

                    int   n1 = n + 1;
                    int **sd = _simultaneous_SameDivisor(arr, n, alpha, epsilon);

                    for (int i = 0; i < n1; i++)
                    {
                        result[i] = new int[n1];
                        for (int j = 0; j < n1; j++)
                        {
                            result[i][j] = sd[i][j];
                        }
                    }

                    ReleaseMemoryIntPtrPtr(sd, n1);
                }
            }

            return(result);
        }
Exemplo n.º 6
0
 public static unsafe void Test()
 {
     fixed(int *a = &i)
     {
         int **x = &a;
     }
 }
Exemplo n.º 7
0
 public static void Duplicate(int** values, int numValues)
 {
     int* newArray = (int*)Marshal.AllocCoTaskMem(sizeof(int) * numValues);
     new Span<int>(*values, numValues).CopyTo(new Span<int>(newArray, numValues));
     Marshal.FreeCoTaskMem((IntPtr)(*values));
     *values = newArray;
 }
        private void ShowBound()
        {
            fragInstGta *inst = nativeVeh->Inst;

            if (inst == null)
            {
                return;
            }

            fragCacheEntry *entry = inst->CacheEntry;

            if (entry == null)
            {
                return;
            }

            int **flags = entry->BrokenAndHiddenComponentsFlags;

            if (flags == null)
            {
                return;
            }

            (*flags)[boundIndex >> 5] &= ~(1 << (boundIndex & 0x1F));
        }
Exemplo n.º 9
0
        public static bool klv_init(bilist ***lbucket_ptr, /* space for left bucket sorts */
                                    bilist ***rbucket_ptr, /* space for right bucket sorts */
                                    bilist **llistspace,   /* space for elements of linked lists */
                                    bilist **rlistspace,   /* space for elements of linked lists */
                                    int **ldvals,          /* change in separator for left moves */
                                    int **rdvals,          /* change in separator for right moves */
                                    int nvtxs,             /* number of vertices in the graph */
                                    int maxchange          /* maximum change by moving a vertex */
                                    )
        {
            int sizeb; /* size of set of buckets */
            int sizel; /* size of set of pointers for all vertices */

            /* Allocate appropriate data structures for buckets, and listspace. */

            sizeb = (2 * maxchange + 1) * sizeof(bilist *);
            *lbucket_ptr = (bilist **)Marshal.AllocHGlobal(sizeb);
            *rbucket_ptr = (bilist **)Marshal.AllocHGlobal(sizeb);

            *ldvals = (int *)Marshal.AllocHGlobal((nvtxs + 1) * sizeof(int));
            *rdvals = (int *)Marshal.AllocHGlobal((nvtxs + 1) * sizeof(int));

            sizel = (nvtxs + 1) * sizeof(bilist);
            *llistspace = (bilist *)Marshal.AllocHGlobal(sizel);
            *rlistspace = (bilist *)Marshal.AllocHGlobal(sizel);

            return(*lbucket_ptr == null || *rbucket_ptr == null || *ldvals == null || *rdvals == null ||
                   *llistspace == null || *rlistspace == null);
        }
Exemplo n.º 10
0
 private static extern unsafe bool InitProblem(
     int vertexCount,
     int clusterCount,
     int *weights,
     int *clusterSizes,
     int **clusters,
     bool isSymmetric);
        /// <summary>
        /// This method executes the workflow for the session.
        /// </summary>
        public void Execute(
            ulong rowsNumber,
            void **data,
            int **strLenOrNullMap,
            ushort *outputSchemaColumnsNumber)
        {
            Logging.Trace("CSharpSession::Execute");
            _inputDataSet.AddColumns(rowsNumber, data, strLenOrNullMap);
            _userDll.UserExecutor = _userDll.InstantiateUserExecutor();

            if (_userDll.UserExecutor != null)
            {
                _outputDataSet.CSharpDataFrame = _userDll.UserExecutor.Execute(_inputDataSet.CSharpDataFrame, _paramContainer.UserParams);
            }

            if (_outputDataSet.CSharpDataFrame != null)
            {
                _outputDataSet.ColumnsNumber = (ushort)_outputDataSet.CSharpDataFrame.Columns.Count;
                _outputDataSet.ExtractColumns(_outputDataSet.CSharpDataFrame);
                *outputSchemaColumnsNumber = _outputDataSet.ColumnsNumber;
            }
            else
            {
                *outputSchemaColumnsNumber = 0;
            }
        }
Exemplo n.º 12
0
 public static int test_0_conv_u()
 {
     unsafe {
         int **dead = (int **)0xdeadbeaf;
         long  i    = (long)dead;
         return((i == 0xdeadbeaf) ? 0 : 1);
     }
 }
Exemplo n.º 13
0
        public static int ReturnAsOutIntArray(int hr, int **ret)
        {
            const int NumBytesInInt = sizeof(int);

            *ret = (int *)Marshal.AllocCoTaskMem(sizeof(int) * NumBytesInInt);
            new Span <int>(*ret, NumBytesInInt).Fill(hr);
            return(hr);
        }
Exemplo n.º 14
0
 public static void DuplicatePointers(int*** values, int numValues)
 {
     int sizeInBytes = sizeof(int*) * numValues;
     int** newArray = (int**)Marshal.AllocCoTaskMem(sizeInBytes);
     new Span<byte>(*values, sizeInBytes).CopyTo(new Span<byte>(newArray, sizeInBytes));
     Marshal.FreeCoTaskMem((IntPtr)(*values));
     *values = newArray;
 }
Exemplo n.º 15
0
Arquivo: Grid.cs Projeto: xyuan/BoSSS
        /// <summary>
        /// Create a BoSSS grid from an OpenFOAM mesh
        /// </summary>
        /// <param name="_ref"></param>
        /// <param name="ierr">output, error code; on success, set to 0</param>
        /// <param name="faces">
        /// point labels (indices) of faces, according to OpenFOAM polymesh description (array of arrays)
        /// </param>
        /// <param name="vertices_per_face">
        /// number of vertices for each face
        /// </param>
        /// <param name="nCells">
        /// number of cells in OpenFOAM polymesh
        /// </param>
        /// <param name="neighbour">
        /// Neighbor cell labels for internal faces
        /// </param>
        /// <param name="owner">
        /// for each face, the owner cell label
        /// </param>
        /// <param name="nPoints">number of points/vertices</param>
        /// <param name="nFaces">
        /// number of faces
        /// </param>
        /// <param name="nInternalFaces">
        /// number of internal faces
        /// </param>
        /// <param name="points">
        /// point coordinates, array of <paramref name="nPoints"/>*3
        /// </param>
        unsafe public static void CreateGrid(out int _ref,
                                             ref int nPoints, ref int nCells, ref int nFaces, ref int nInternalFaces,
                                             int **faces,
                                             int *vertices_per_face,
                                             int *neighbour,
                                             int *owner,
                                             double *points,
                                             out int ierr)
        {
            try {
                // copy data (unmanaged to managed)
                int[][] _faces     = new int[nFaces][];
                int[]   _neighbour = new int[nInternalFaces];
                int[]   _owner     = new int[nFaces];
                double[,] _points = new double[nPoints, 3];

                for (int i = 0; i < nFaces; i++)
                {
                    int N = vertices_per_face[i];
                    _faces[i] = new int[N];
                    for (int n = 0; n < N; n++)
                    {
                        _faces[i][n] = faces[i][n];
                    }
                }

                for (int i = 0; i < nInternalFaces; i++)
                {
                    _neighbour[i] = neighbour[i];
                }

                for (int i = 0; i < nFaces; i++)
                {
                    _owner[i] = owner[i];
                }

                for (int i = 0; i < nPoints; i++)
                {
                    _points[i, 0] = points[i * 3 + 0];
                    _points[i, 0] = points[i * 3 + 1];
                    _points[i, 0] = points[i * 3 + 2];
                }


                // create BoSSS grid
                GridData g = FOAMmesh_to_BoSSS(nCells, _faces, _neighbour, _owner, _points);

                // register object
                _ref = Infrastructure.RegisterObject(g);
                ierr = 0;
                return;
            } catch (Exception e) {
                ierr = Infrastructure.ErrorHandler(e);
                _ref = -1;
                return;
            }
        }
Exemplo n.º 16
0
 public unsafe short *this[int **x]
 {
     get { return(null); }
     set
     {
         short y = 2;
         return(&y);
     }
 }
Exemplo n.º 17
0
        FLAC__StreamDecoderWriteStatus WriteCallback(IntPtr decoder,
                                                     FLAC__Frame *frame, int **buffer, void *client_data)
        {
            int sampleCount = frame->header.blocksize;

            if (m_bufferLength > 0)
            {
                throw new Exception("received unrequested samples");
            }

            if ((frame->header.bits_per_sample != m_pcm.BitsPerSample) ||
                (frame->header.channels != m_pcm.ChannelCount) ||
                (frame->header.sample_rate != m_pcm.SampleRate))
            {
                throw new Exception("format changes within a file are not allowed");
            }

            if (m_bufferOffset != 0)
            {
                throw new Exception("internal buffer error");
            }

            if (m_sampleBuffer == null || m_sampleBuffer.Size < sampleCount)
            {
                m_sampleBuffer = new AudioBuffer(m_pcm, sampleCount);
            }
            m_sampleBuffer.Length = sampleCount;

            if (m_pcm.ChannelCount == 2)
            {
                m_sampleBuffer.Interlace(0, (int *)buffer[0], (int *)buffer[1], sampleCount);
            }
            else
            {
                int _channelCount = m_pcm.ChannelCount;
                for (Int32 iChan = 0; iChan < _channelCount; iChan++)
                {
                    fixed(int *pMyBuffer = &m_sampleBuffer.Samples[0, iChan])
                    {
                        int *pMyBufferPtr   = pMyBuffer;
                        int *pFLACBuffer    = buffer[iChan];
                        int *pFLACBufferEnd = pFLACBuffer + sampleCount;

                        while (pFLACBuffer < pFLACBufferEnd)
                        {
                            *pMyBufferPtr = *pFLACBuffer;
                            pMyBufferPtr += _channelCount;
                            pFLACBuffer++;
                        }
                    }
                }
            }
            m_bufferLength  = sampleCount;
            m_sampleOffset += m_bufferLength;
            return(FLAC__StreamDecoderWriteStatus.FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE);
        }
Exemplo n.º 18
0
 static unsafe void PointersAsArgsTest(int *ip, int **ipp, int *[] ipa, int **[] ippa,
                                       DateTime *dtp, DateTime **dtpp, DateTime *[] dtpa, DateTime **[] dtppa)
 {
     Console.WriteLine($"break here!");
     if (ip == null)
     {
         Console.WriteLine($"ip is null");
     }
     Console.WriteLine($"done!");
 }
Exemplo n.º 19
0
        unsafe public OpenFOAMGrid(
            int nPoints, int nCells, int nFaces, int nInternalFaces,
            int **faces,
            int *vertices_per_face,
            int *neighbour,
            int *owner,
            double *points) :
            base(new[] { Cube.Instance }, new[] { Square.Instance }) //
        {
            // copy data (unmanaged to managed)
            int[][] _faces     = new int[nFaces][];
            int[]   _neighbour = new int[nInternalFaces];
            int[]   _owner     = new int[nFaces];
            double[,] _points = new double[nPoints, 3];

            //Debug.Assert(nFaces == GridImportTest.faces.Length, "mism nFaces len");
            for (int i = 0; i < nFaces; i++)
            {
                int N = vertices_per_face[i];
                //Debug.Assert(N == GridImportTest.faces[i].Length, "mism nVerts face " + i);
                _faces[i] = new int[N];
                for (int n = 0; n < N; n++)
                {
                    _faces[i][n] = faces[i][n];
                    //Debug.Assert(_faces[i][n] == GridImportTest.faces[i][n], "mism face " + i + " vert " + n);
                }
            }

            //Debug.Assert(nInternalFaces == GridImportTest.neighbour.Length, "mismatch neighbour length");
            for (int i = 0; i < nInternalFaces; i++)
            {
                _neighbour[i] = neighbour[i];
                //Debug.Assert(_neighbour[i] == GridImportTest.neighbour[i], "neighbour " + i + " mismatch ");
            }

            for (int i = 0; i < nFaces; i++)
            {
                _owner[i] = owner[i];
                //Debug.Assert(_owner[i] == GridImportTest.owner[i], "owner " + i + " mismatch ");
            }

            for (int i = 0; i < nPoints; i++)
            {
                _points[i, 0] = points[i * 3 + 0];
                _points[i, 1] = points[i * 3 + 1];
                _points[i, 2] = points[i * 3 + 2];
            }


            // create BoSSS grid
            FOAMmesh_to_BoSSS(this, nCells, _faces, _neighbour, _owner, _points);

            // create grid data object
            this.GridDataObject = new GridData(this);
        }
Exemplo n.º 20
0
Arquivo: CApi.cs Projeto: horker/py2cs
 public static extern unsafe int MXSymbolInferType(SymbolHandle sym,
                                                   mx_uint num_args,
                                                   [MarshalAs(UnmanagedType.LPUTF8Str)] string[] keys,
                                                   int[] arg_type_data,
                                                   int[] in_type_size,
                                                   int **in_type_data,
                                                   out int[] out_type_size,
                                                   out int[] out_type_data,
                                                   out mx_uint aux_type_size,
                                                   out int[] aux_type_data,
                                                   out int complete);
    static unsafe int Main()
    {
        int * a = null;
        int **b = &a;

        if (*b == null)
        {
            return(0);
        }
        return(1);
    }
Exemplo n.º 22
0
        public unsafe static int[][] ToIntArray(int **array_ptr, long *count_ptr, long length)
        {
            var array_count = ToLongArray(count_ptr, length);
            var array       = new int[array_count.Length][];

            for (int i = 0; i < array_count.Length; i++)
            {
                array[i] = ToIntArray(array_ptr[i], array_count[i]);
            }
            Free(new IntPtr(array_ptr));
            return(array);
        }
Exemplo n.º 23
0
        public static int SumPointers(int** values, int numValues)
        {
            if (values == null)
                return -1;

            int sum = 0;
            for (int i = 0; i < numValues; i++)
            {
                sum += *values[i];
            }
            return sum;
        }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            unsafe
            {
                int *x;

                int y = 10;

                x = &y;

                uint addr = (uint)x;

                Console.WriteLine("The address of the variable y: {0}", addr);

                byte *bytePointers = (byte *)(addr + 4);
                Console.WriteLine("Byte value at {0}: {1}", addr + 4, *bytePointers);

                uint oldAddr    = (uint)bytePointers - 4;
                int *intPointer = (int *)oldAddr;
                Console.WriteLine("Int value at {0}: {1}", oldAddr, *intPointer);

                double *doublePointer = (double *)(addr + 4);
                Console.WriteLine("Double value at {0}: {1}", addr + 4, *doublePointer);

                //***********************************************************************//

                char *charPointer = (char *)123500;
                charPointer += 4;
                Console.WriteLine("Adress: {0}", (uint)charPointer);

                //***********************************************************************//
            }

            Console.ReadLine();

            //Pointer to pointer.
            unsafe
            {
                int *x;
                int  y = 10;

                x = &y;
                int **z = &x;
                **    z = **z + 40;
                Console.WriteLine(y);

                Console.WriteLine(**z);
            }

            Console.ReadLine();
        }
        public static unsafe void ReadWriteDoublePointer()
        {
            int   value1          = 10;
            int   value2          = 20;
            int * valueAddress    = (int *)Unsafe.AsPointer(ref value1);
            int **valueAddressPtr = &valueAddress;

            Unsafe.Write(valueAddressPtr, new IntPtr(&value2));

            Assert.Equal(20, *(*valueAddressPtr));
            Assert.Equal(20, Unsafe.Read <int>(valueAddress));
            Assert.Equal(new IntPtr(valueAddress), Unsafe.Read <IntPtr>(valueAddressPtr));
            Assert.Equal(20, Unsafe.Read <int>(Unsafe.Read <IntPtr>(valueAddressPtr).ToPointer()));
        }
Exemplo n.º 26
0
        public static void coarsen1(vtx_data **graph,    /* array of vtx data for graph */
                                    int nvtxs,           /* number of vertices in graph */
                                    int nedges,          /* number of edges in graph */
                                    vtx_data ***pcgraph, /* coarsened version of graph */
                                    int *pcnvtxs,        /* number of vtxs in coarsened graph */
                                    int *pcnedges,       /* number of edges in coarsened graph */
                                    int **pv2cv,         /* pointer to v2cv */
                                    int igeom,           /* dimension for geometric information */
                                    float **coords,      /* coordinates for vertices */
                                    float **ccoords,     /* coordinates for coarsened vertices */
                                    bool useEdgeWeights  /* are edge weights being used? */
                                    )
        {
            double time;    /* time routine is entered */
            int *  v2cv;    /* maps from vtxs to cvtxs */
            int *  mflag;   /* flag indicating vtx matched or not */
            int    cnvtxs;  /* number of vtxs in coarse graph */
            int    nmerged; /* number of edges contracted */

            time = seconds();

            /* Allocate and initialize space. */
            v2cv  = (int *)Marshal.AllocHGlobal((nvtxs + 1) * sizeof(int));
            mflag = (int *)Marshal.AllocHGlobal((nvtxs + 1) * sizeof(int));

            /* Find a maximal matching in the graph. */
            nmerged     = maxmatch(graph, nvtxs, nedges, mflag, useEdgeWeights, igeom, coords);
            match_time += seconds() - time;

            /* Now construct coarser graph by contracting along matching edges. */
            /* Pairs of values in mflag array indicate matched vertices. */
            /* A zero value indicates that vertex is unmatched. */

            /*
             *  makecgraph(graph, nvtxs, pcgraph, pcnvtxs, pcnedges, mflag, *pv2cv, nmerged, useEdgeWeights, igeom, coords, ccoords);
             *  makecgraph2(graph, nvtxs, nedges, pcgraph, pcnvtxs, pcnedges, mflag, *pv2cv, nmerged, useEdgeWeights, igeom, coords, ccoords);
             */

            makev2cv(mflag, nvtxs, v2cv);

            Marshal.FreeHGlobal((IntPtr)mflag);

            cnvtxs = nvtxs - nmerged;
            makefgraph(graph, nvtxs, nedges, pcgraph, cnvtxs, pcnedges, v2cv, useEdgeWeights, igeom, coords,
                       ccoords);

            *pcnvtxs = cnvtxs;
            *pv2cv   = v2cv;
            coarsen_time += seconds() - time;
        }
Exemplo n.º 27
0
        public static int SumInArray(int** values, int numValues)
        {
            if (*values == null)
            {
                return -1;
            }

            int sum = 0;
            for (int i = 0; i < numValues; i++)
            {
                sum += (*values)[i];
            }
            return sum;
        }
Exemplo n.º 28
0
        public static int** TransposeMatrix(int** matrix, int* numRows, int numColumns)
        {
            int** newRows = (int**)Marshal.AllocCoTaskMem(numColumns * sizeof(int*));
            for (int i = 0; i < numColumns; i++)
            {
                newRows[i] = (int*)Marshal.AllocCoTaskMem(numRows[i] * sizeof(int));
                for (int j = 0; j < numRows[i]; j++)
                {
                    newRows[i][j] = matrix[j][i];
                }
            }

            return newRows;
        }
Exemplo n.º 29
0
        /*
         * Домашнее задание
         * Сделать проект с небезопасным кодом
         * Поработать с указателями (получить ссылку, передать ссылку, прочитать адрес, прочитать значение)
         * Создать указатель на указатель
         */

        static void Main(string[] args)
        {
            // небезопасный код
            unsafe
            {
                int i = 30;

                int *x, y;

                // даем имя для определенного участка памяти
                int *address = &i;

                Console.WriteLine(*address);
                Console.WriteLine((long)address);

                Console.WriteLine(i);
                *address = 20;

                Console.WriteLine(*address);
                Console.WriteLine(i);

                Console.WriteLine();

                int a = 5;
                int b = 7;

                Console.WriteLine("b = " + *(&a + 1));

                Calc(a, &b);

                Console.WriteLine(a);
                Console.WriteLine(b);

                Console.WriteLine();

                int *adddres2 = address + 4;
                *    adddres2 = 777;

                Console.WriteLine(*adddres2);

                int **adr = &address;

                Console.WriteLine("**");
                Console.WriteLine((long)adr);
                Console.WriteLine((long)*adr);
                Console.WriteLine(**adr);
            }

            Console.ReadLine();
        }
Exemplo n.º 30
0
        unsafe public Window3()
        {
            InitializeComponent();
            taille = 10;
            WrapperAlgo wa = new WrapperAlgo(taille);

            int **tabCarte = wa.remplirCarte();
            int   xJ1      = 0;
            int   yJ1      = 0;
            int   xJ2      = 0;
            int   yJ2      = 0;

            wa.positionJoueur(&xJ1, &yJ1, &xJ2, &yJ2);
        }
Exemplo n.º 31
0
        /// <summary>
        /// Metoda typu Coarse-grained, realizująca ważone nakładanie obrazów.
        /// </summary>
        public unsafe void BlendImages()
        {
            #region Load Bitmap
            LoadImagesFromUserPaths();

            SetMaxArraySize();
            CropAllImagesToMaxArraySize();

            WriteableBitmap img1Bitmap = new WriteableBitmap(croppedBmpList[0]);
            WriteableBitmap img2Bitmap = new WriteableBitmap(croppedBmpList[1]);
            #endregion

            #region Initialization

            int linePadding; // liczba bajtów wyrównujacych wiersz do wielokrotności 4
            int moduloFromDivWidthByFour = ((int)Math.Round(croppedBmpList[0].Width) * 3) % 4;

            /*
             * Ustalenie odpowiedniego wyrównania, jeśli wiersz dzieli się przez 4 bez reszty, wtedy w zapisie dodatkowe bajty nie występują
             * w przeciwnym wypadku wyrównanie równa się liczbie brakujących bajtów aby wiersz był wielokrotnością 4.
             */
            linePadding = (moduloFromDivWidthByFour == 0) ? 0 : (4 - moduloFromDivWidthByFour);

            int stride = ((int)Math.Round(croppedBmpList[0].Width) * 4) + linePadding; // rozmiar wiersza w bajtach

            int arraySize = stride * (int)Math.Round(croppedBmpList[0].Height);       // rozmiar tablicy pikseli (ilosc_bajtow_w_wierszu * liczba_wierszy)

            img1PixelsByte = new byte[arraySize];            // tablice pikseli
            img2PixelsByte = new byte[arraySize];

            img1Bitmap.CopyPixels(img1PixelsByte, stride, 0);  // kopiowanie tablicy pikseli z bitmapy do tablicy bajtów, z ustalonym krokiem, zaczynając od 0
            img2Bitmap.CopyPixels(img2PixelsByte, stride, 0);
            #endregion

            /*
             * Jeśli będzie używany algortym z biblioteki ASM należy
             * utworzyć tablicę pikseli, w postaci wskaźników.
             */
            if (appSettings.LoadAsmLibrary == true)
            {
                intBitmapsList = createIntArrayFromByte();
            }
            else
            {
                byteBitmapsList = new byte[2][];

                byteBitmapsList[0] = img1PixelsByte;
                byteBitmapsList[1] = img2PixelsByte;
            }
            #region Main Algorithm

            int bytesPerPixel =  img1Bitmap.Format.BitsPerPixel / 8;
            int pixelsNumber = arraySize / bytesPerPixel;  // liczba wszystkich pikseli

            threadPixelsStep = pixelsNumber / appSettings.ThreadNumber; // liczba pikseli dla pojedyńczego wątku

            /**
             * Jeśli nie można dokonać równego podziału to zostaje stworzonych n - 1 wątków
             * z regularnym krokiem, gdzie n - liczba wątków zadana przez użytkownika,
             * natomiast wątek n który wykonuje obliczenia dla pozostałej reszty pikseli.
             *
             * W przeciwnym wypadku zostaje utworzonych n regularnych wątków.
             */
            if ( threadPixelsStep * bytesPerPixel * appSettings.ThreadNumber != arraySize)
            {
                int delta = pixelsNumber - ( threadPixelsStep * appSettings.ThreadNumber);

                createThreadList(appSettings.ThreadNumber-1);   // utworzenie n-1 wątków

                int start = threadPixelsStep * (appSettings.ThreadNumber - 1);
                int[] coords = { start, arraySize / bytesPerPixel };
                createNewThread(coords); // utworzenie n-tego wątku obliczającego pozostałe piksele

            }
            else
            {
                createThreadList(appSettings.ThreadNumber);
            }

            Stopwatch clock = new Stopwatch();
            clock.Start();

            //uruchomienie wszystkich wątków
            foreach (Thread th in threadList)
            {
                th.Start();
            }

            //oczekiwanie na zakończenie obliczeń przez wszystkie wątki
            foreach (Thread th in threadList)
            {
                th.Join();
            }

            clock.Stop();
            appSettings.ResultTime = "Czas wykonania " + clock.ElapsedMilliseconds.ToString() + " ms.";

            #endregion

            #region Save Result Bitmap

            if (appSettings.LoadAsmLibrary == true)
            {
                copyAsmResultToImg1PixelsByte();
            }
            Int32Rect rect = new Int32Rect(0, 0, maxWidth, maxHeight);
            img1Bitmap.WritePixels(rect, img1PixelsByte, stride, 0); // zapisanie wyniku obliczeń do bitmapy

            SaveDialog(img1Bitmap); //zapisanie bitmapy na dysku
            #endregion
        }