Beispiel #1
0
        private static void _ProcessBitmap(Bitmap imageData, Func <Tuple <byte, byte, byte>, Tuple <byte, byte, byte> > processRGB)
        {
            using (var bmLock = new BitmapLocker(imageData))
            {
                int           stride = bmLock.BitmapData.Stride;
                System.IntPtr Scan0  = bmLock.BitmapData.Scan0;
                unsafe
                {
                    byte *p = (byte *)(void *)Scan0;
                    byte  red, green, blue;
                    int   nOffset = stride - imageData.Width * 3;
                    for (int y = 0; y < imageData.Height; ++y)
                    {
                        for (int x = 0; x < imageData.Width; ++x)
                        {
                            blue  = p[0];
                            green = p[1];
                            red   = p[2];

                            var result = processRGB(Tuple.Create(red, green, blue));
                            p[0] = result.Item3;
                            p[1] = result.Item2;
                            p[2] = result.Item1;

                            p += 3;
                        }
                        p += nOffset;
                    }
                }
            }
        }
Beispiel #2
0
 public void Apply(Bitmap input, Bitmap output)
 {
     using (var inputLock = new BitmapLocker(input, ImageLockMode.ReadOnly))
         using (var outputLock = new BitmapLocker(output))
         {
             // TBD
         }
 }
 public void Apply(Bitmap input, Bitmap output)
 {
     using (var inputLock = new BitmapLocker(input, ImageLockMode.ReadOnly))
     using (var outputLock = new BitmapLocker(output))
     {
         // TBD
     }
 }
        private static void _ProcessBitmap(Bitmap imageData, Func<Tuple<byte, byte, byte>, Tuple<byte, byte, byte>> processRGB)
        {
            using (var bmLock = new BitmapLocker(imageData))
            {
                int stride = bmLock.BitmapData.Stride;
                System.IntPtr Scan0 = bmLock.BitmapData.Scan0;
                unsafe
                {
                    byte* p = (byte*)(void*)Scan0;
                    byte red, green, blue;
                    int nOffset = stride - imageData.Width * 3;
                    for (int y = 0; y < imageData.Height; ++y)
                    {
                        for (int x = 0; x < imageData.Width; ++x)
                        {
                            blue = p[0];
                            green = p[1];
                            red = p[2];

                            var result = processRGB(Tuple.Create(red, green, blue));
                            p[0] = result.Item3;
                            p[1] = result.Item2;
                            p[2] = result.Item1;

                            p += 3;
                        }
                        p += nOffset;
                    }
                }
            }
        }