Esempio n. 1
0
        /// <summary>
        /// Implements the operator |.
        /// </summary>
        /// <param name="Image1">The first image.</param>
        /// <param name="Image2">The second image</param>
        /// <returns>The result of the operator.</returns>
        public static SwiftBitmap operator |(SwiftBitmap Image1, SwiftBitmap Image2)
        {
            Contract.Requires <ArgumentNullException>(Image1 != null, "Image1");
            Contract.Requires <ArgumentNullException>(Image2 != null, "Image2");
            Image1.Lock();
            Image2.Lock();
            var Result = new SwiftBitmap(Image1.Width, Image1.Height);

            Result.Lock();
            Parallel.For(0, Result.Width, x =>
            {
                for (int y = 0; y < Result.Height; ++y)
                {
                    var Pixel1 = Image1.GetPixel(x, y);
                    var Pixel2 = Image2.GetPixel(x, y);
                    Result.SetPixel(x, y,
                                    Color.FromArgb(Pixel1.R | Pixel2.R,
                                                   Pixel1.G | Pixel2.G,
                                                   Pixel1.B | Pixel2.B));
                }
            });
            Image2.Unlock();
            Image1.Unlock();
            return(Result.Unlock());
        }