Esempio n. 1
0
        public static int[] CopyImgBuffer(ActualImage img, int width)
        {
            //calculate stride for the width

            int destStride = ActualImage.CalculateStride(width, PixelFormat.ARGB32);
            int h          = img.Height;
            int newBmpW    = destStride / 4;

            int[] buff2 = new int[newBmpW * img.Height];
            unsafe
            {
                TempMemPtr srcBufferPtr = ActualImage.GetBufferPtr(img);
                byte *     srcBuffer    = (byte *)srcBufferPtr.Ptr;
                int        srcIndex     = 0;
                int        srcStride    = img.Stride;
                fixed(int *destHead = &buff2[0])
                {
                    byte *destHead2 = (byte *)destHead;

                    for (int line = 0; line < h; ++line)
                    {
                        //System.Runtime.InteropServices.Marshal.Copy(srcBuffer, srcIndex, (IntPtr)destHead2, destStride);
                        NaitveMemMx.memcpy((byte *)destHead2, srcBuffer + srcIndex, destStride);
                        srcIndex  += srcStride;
                        destHead2 += destStride;
                    }
                }

                srcBufferPtr.Release();
            }

            return(buff2);
        }
Esempio n. 2
0
 public static unsafe void memmove(byte *dest, int destIndex, byte *source, int sourceIndex, int count)
 {
     if (source != dest ||
         destIndex < sourceIndex)
     {
         NaitveMemMx.memcpy(dest + destIndex, source + sourceIndex, count);
         // memcpy(dest, destIndex, source, sourceIndex, Count);
     }
     else
     {
         throw new Exception("this code needs to be tested");
     }
 }
Esempio n. 3
0
        public static int[] CopyImgBuffer(ActualImage src, int srcX, int srcY, int srcW, int srcH)
        {
            //calculate stride for the width
            int destStride = ActualImage.CalculateStride(srcW, PixelFormat.ARGB32);
            int newBmpW    = destStride / 4;

            int[] buff2 = new int[newBmpW * srcH];
            unsafe
            {
                TempMemPtr srcBufferPtr = ActualImage.GetBufferPtr(src);
                byte *     srcBuffer    = (byte *)srcBufferPtr.Ptr;
                int        srcIndex     = 0;
                int        srcStride    = src.Stride;
                fixed(int *destHead = &buff2[0])
                {
                    byte *destHead2 = (byte *)destHead;

                    //move to specific src line
                    srcIndex += srcStride * srcY;

                    int lineEnd = srcY + srcH;

                    for (int line = srcY; line < lineEnd; ++line)
                    {
                        //System.Runtime.InteropServices.Marshal.Copy(srcBuffer, srcIndex, (IntPtr)destHead2, destStride);
                        NaitveMemMx.memcpy((byte *)destHead2, srcBuffer + srcIndex, destStride);
                        srcIndex  += srcStride;
                        destHead2 += destStride;
                    }
                }

                srcBufferPtr.Release();
            }

            return(buff2);
        }