Beispiel #1
0
        void Combine(BinaryMap source, RectangleC area, Point at, CombineFunction function)
        {
            int shift      = (int)((uint)area.X & WordMask) - (int)((uint)at.X & WordMask);
            int vectorSize = (area.Width >> WordShift) + 2;

            Parallel.For(0, area.Height,
                         () => new CombineLocals {
                Vector = new uint[vectorSize], SrcVector = new uint[vectorSize]
            },
                         delegate(int y, ParallelLoopState state, CombineLocals locals)
            {
                LoadLine(locals.Vector, new Point(at.X, at.Y + y), area.Width);
                source.LoadLine(locals.SrcVector, new Point(area.X, area.Y + y), area.Width);
                if (shift >= 0)
                {
                    ShiftLeft(locals.SrcVector, shift);
                }
                else
                {
                    ShiftRight(locals.SrcVector, -shift);
                }
                function(locals.Vector, locals.SrcVector);
                SaveLine(locals.Vector, new Point(at.X, at.Y + y), area.Width);
                return(locals);
            }, locals => { });
        }
Beispiel #2
0
 public void AndNot(BinaryMap source, RectangleC area, Point at)
 {
     Combine(source, area, at, delegate(uint[] target, uint[] srcVector)
     {
         for (int i = 0; i < target.Length; ++i)
         {
             target[i] &= ~srcVector[i];
         }
     });
 }
Beispiel #3
0
 public BinaryMap(BinaryMap other)
 {
     Width     = other.Width;
     Height    = other.Height;
     WordWidth = other.WordWidth;
     Map       = new uint[other.Map.GetLength(0), other.Map.GetLength(1)];
     for (int y = 0; y < Map.GetLength(0); ++y)
     {
         for (int x = 0; x < Map.GetLength(1); ++x)
         {
             Map[y, x] = other.Map[y, x];
         }
     }
 }
Beispiel #4
0
        public BinaryMap FillCornerAreas(BlockMap blocks)
        {
            BinaryMap result = new BinaryMap(blocks.PixelCount);

            Parallel.For(0, blocks.CornerCount.Height, delegate(int cornerY)
            {
                for (int cornerX = 0; cornerX < blocks.CornerCount.Width; ++cornerX)
                {
                    if (GetBit(cornerX, cornerY))
                    {
                        result.Fill(blocks.CornerAreas[cornerY, cornerX]);
                    }
                }
            });
            return(result);
        }
Beispiel #5
0
        public BinaryMap FillBlocks(BlockMap blocks)
        {
            BinaryMap result = new BinaryMap(blocks.PixelCount);

            Parallel.For(0, blocks.BlockCount.Height, delegate(int blockY)
            {
                for (int blockX = 0; blockX < blocks.BlockCount.Width; ++blockX)
                {
                    if (GetBit(blockX, blockY))
                    {
                        result.Fill(blocks.BlockAreas[blockY, blockX]);
                    }
                }
            });
            return(result);
        }
Beispiel #6
0
        public BinaryMap GetInverted()
        {
            BinaryMap result = new BinaryMap(Size);

            for (int y = 0; y < Map.GetLength(0); ++y)
            {
                for (int x = 0; x < Map.GetLength(1); ++x)
                {
                    result.Map[y, x] = ~Map[y, x];
                }
            }
            if (((uint)Width & WordMask) != 0u)
            {
                for (int y = 0; y < Map.GetLength(0); ++y)
                {
                    result.Map[y, Map.GetLength(1) - 1] &= ~0u >> (WordSize - (int)((uint)Width & WordMask));
                }
            }
            return(result);
        }
Beispiel #7
0
        public void Copy(BinaryMap source, RectangleC area, Point at)
        {
            int shift = (int)((uint)area.X & WordMask) - (int)((uint)at.X & WordMask);

            Parallel.For(0, area.Height,
                         () => new uint[(area.Width >> WordShift) + 2],
                         delegate(int y, ParallelLoopState state, uint[] vector)
            {
                source.LoadLine(vector, new Point(area.X, area.Y + y), area.Width);
                if (shift >= 0)
                {
                    ShiftLeft(vector, shift);
                }
                else
                {
                    ShiftRight(vector, -shift);
                }
                SaveLine(vector, new Point(at.X, at.Y + y), area.Width);
                return(vector);
            }, vector => { });
        }
Beispiel #8
0
 public void AndNot(BinaryMap source)
 {
     AndNot(source, Rect, new Point());
 }
Beispiel #9
0
 public void OrNot(BinaryMap source)
 {
     OrNot(source, Rect, new Point());
 }
Beispiel #10
0
 public void Xor(BinaryMap source)
 {
     Xor(source, Rect, new Point());
 }
Beispiel #11
0
 public void Copy(BinaryMap source)
 {
     Copy(source, Rect, new Point());
 }