I have a bitmap sourceImage.bmp
bit lock:
BitmapData dataOriginal = sourceImage.LockBits(new Rectangle(0, 0, sourceImage.Width, sourceImage.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
Do an analysis, get a clone :
Bitmap originalClone = AForge.Imaging.Image.Clone(dataOriginal);
unlock bit:
sourceImage.UnlockBits(dataOriginal);
Is it possible to indicate which part of "dataOriginal" to copy (x, y, w, h)? or create new data from the original data by determining the coordinates of X and Y, as well as H and W?
The goal is to copy a small area from this image. This method may be faster than DrawImage, so I do not use the latter.
Edit:
So, I took a 29 MB bitmap and did some hardcore testing! Full-sized crop (mostly copy) + 100 iterations.

the code:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using AForge; using AForge.Imaging; using System.Diagnostics; using System.Drawing.Imaging; using System.IO; using System.Runtime.InteropServices; namespace testCropClone { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private unsafe Bitmap Clone(Bitmap bmp, int startX, int startY, int width, int height) { Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); BitmapData rawOriginal = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); int origByteCount = rawOriginal.Stride * rawOriginal.Height; byte[] origBytes = new Byte[origByteCount]; Marshal.Copy(rawOriginal.Scan0, origBytes, 0, origByteCount); int BPP = 4;
Edit2: (Assumption of a full-sized crop ..) method Nr. 2
for (int i = 0; i < 100; i++) { Crop crop = new Crop(new Rectangle(0, 0, source.Width, source.Height)); var source2 = crop.Apply(source); source2.Dispose(); }
Average value = 62 ms (40 ms less than the 1st Afarge approach)
Results:
- BitmapClone (0 ms) ?? (cheating, right?)
- Aforge # 2 (65 ms)
- Aforge # 1 (105 ms)
- Rectangle (170 ms)
- Bit lock (803 ms) (waiting for corrections / new test results).