/// <summary> /// Locks this bitmap into memory and returns a FastBitmap that can be used to manipulate its pixels /// </summary> /// <param name="bitmap">The bitmap to lock</param> /// <param name="lockFormat">The underlying pixel format to use when locking the bitmap</param> /// <returns>A locked FastBitmap</returns> public static FastBitmap FastLock(this Bitmap bitmap, FastBitmapLockFormat lockFormat) { var fast = new FastBitmap(bitmap); fast.Lock(lockFormat); return(fast); }
/// <summary> /// Locks the bitmap to start the bitmap operations. If the bitmap is already locked, /// an exception is thrown. /// /// The provided pixel format should be a 32bpp format. /// </summary> /// <param name="pixelFormat">A pixel format to use when locking the underlying bitmap</param> /// <returns>A fast bitmap locked struct that will unlock the underlying bitmap after disposal</returns> /// <exception cref="InvalidOperationException">The bitmap is already locked</exception> /// <exception cref="Exception">The locking operation in the underlying bitmap failed</exception> /// <exception cref="InvalidOperationException">The bitmap is already locked outside this fast bitmap</exception> public FastBitmapLocker Lock(FastBitmapLockFormat pixelFormat) { if (Locked) { throw new InvalidOperationException("Unlock must be called before a Lock operation"); } return(Lock(ImageLockMode.ReadWrite, (PixelFormat)pixelFormat)); }