Utilities.Media.SwiftBitmap.Lock C# (CSharp) Méthode

Lock() public méthode

Locks this instance.
public Lock ( ) : SwiftBitmap
Résultat SwiftBitmap
        public unsafe SwiftBitmap Lock()
        {
            Contract.Requires<NullReferenceException>(InternalBitmap != null);
            if (Data != null)
                return this;
            Data = InternalBitmap.LockBits(new Rectangle(0, 0, InternalBitmap.Width, InternalBitmap.Height),
                                            ImageLockMode.ReadWrite,
                                            InternalBitmap.PixelFormat);
            PixelSize = GetPixelSize();
            DataPointer = (byte*)Data.Scan0;
            return this;
        }

Usage Example

Exemple #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());
        }
All Usage Examples Of Utilities.Media.SwiftBitmap::Lock