/// <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> /// <returns>A locked FastBitmap</returns> public static FastBitmap FastLock(this Bitmap bitmap) { FastBitmap fast = new FastBitmap(bitmap); fast.Lock(); return(fast); }
/// <summary> /// Copies a region of the source bitmap to a target bitmap /// </summary> /// <param name="source">The source image to copy</param> /// <param name="target">The target image to be altered</param> /// <param name="srcRect">The region on the source bitmap that will be copied over</param> /// <param name="destRect">The region on the target bitmap that will be changed</param> /// <exception cref="ArgumentException">The provided source and target bitmaps are the same bitmap</exception> public static void CopyRegion(Bitmap source, Bitmap target, Rectangle srcRect, Rectangle destRect) { FastBitmap fastTarget = new FastBitmap(target); using (fastTarget.Lock()) { fastTarget.CopyRegion(source, srcRect, destRect); } }