Example #1
0
 public static void memset_unsafe(IntPtr dest, byte byteValue, int count)
 {
     unsafe
     {
         NativeMemMx.memset((byte *)dest, byteValue, count);
     }
 }
        public static int[] CopyImgBuffer(ActualBitmap img, int width)
        {
            //calculate stride for the width

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

            int[] buff2 = new int[newBmpW * img.Height];
            unsafe
            {
                CpuBlit.Imaging.TempMemPtr srcBufferPtr = ActualBitmap.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);
                        NativeMemMx.memcpy((byte *)destHead2, srcBuffer + srcIndex, destStride);
                        srcIndex  += srcStride;
                        destHead2 += destStride;
                    }
                }

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

            int[] buff2 = new int[newBmpW * srcH];
            unsafe
            {
                CpuBlit.Imaging.TempMemPtr srcBufferPtr = ActualBitmap.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);
                        NativeMemMx.memcpy((byte *)destHead2, srcBuffer + srcIndex, destStride);
                        srcIndex  += srcStride;
                        destHead2 += destStride;
                    }
                }

                srcBufferPtr.Release();
            }

            return(buff2);
        }
Example #5
0
 public static void memset(byte[] dest, int destIndex, byte byteValue, int count)
 {
     NativeMemMx.MemSet(dest, destIndex, byteValue, count);
 }
Example #6
0
 public static unsafe void memcpy(byte *dest, byte *src, int len)
 {
     NativeMemMx.MemCopy(dest, src, len);
 }
Example #7
0
 //----------------------------------------------------------filling_rule_e
 public static void memcpy(byte[] dest,
                           int destIndex, byte[] source,
                           int sourceIndex, int count)
 {
     NativeMemMx.MemCopy(dest, destIndex, source, sourceIndex, count);
 }
Example #8
0
 public static void MemClear(Byte[] dest, int destIndex, int count)
 {
     NativeMemMx.MemSet(dest, destIndex, 0, count);
 }