Beispiel #1
0
    public void And()
    {
        Color color1 = Color.FromArgb(0b00000000_00000000_00000001_00000001);
        Color color2 = Color.FromArgb(0b00000000_00000001_00000000_00000001);

        Assert.AreEqual(Color.FromArgb(0, 0, 0, 1), color1.And(color2));
    }
Beispiel #2
0
        /// <summary>
        /// Modifies the current image to contain the result of a bitwise AND of this Snapshot
        /// and the mask.  This technique can be used to remove data from an image.
        /// http://en.wikipedia.org/wiki/Bitmask#Image_masks
        /// </summary>
        /// <param name="mask">Mask Snapshot to use in the bitwise AND operation.</param>
        public void And(Snapshot mask)
        {
            if (mask.Width != Width || mask.Height != Height)
            {
                throw new InvalidOperationException("mask Snapshot must be of equal size to this Snapshot");
            }

            for (int row = 0; row < Height; row++)
            {
                for (int col = 0; col < Width; col++)
                {
                    Color col1 = this[row, col];
                    Color col2 = mask[row, col];
                    this[row, col] = col1.And(col2);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Modifies the current image to contain the result of a bitwise AND of this Snapshot
        /// and the mask.  This technique can be used to remove data from an image.
        /// http://en.wikipedia.org/wiki/Bitmask#Image_masks
        /// </summary>
        /// <param name="mask">Mask Snapshot to use in the bitwise AND operation.</param>
        public void And(Snapshot mask)
        {
            if (mask.Width != Width || mask.Height != Height)
            {
                throw new InvalidOperationException("mask Snapshot must be of equal size to this Snapshot");
            }

            int thisHeight = Height;
            int thisWidth  = Width;

            Parallel.For(0, thisHeight, (row) =>
            {
                for (int col = 0; col < thisWidth; col++)
                {
                    Color col1     = this[row, col];
                    Color col2     = mask[row, col];
                    this[row, col] = col1.And(col2);
                }
            });
        }