I'm using the following code.
BitmapData bitmapData = bitmap.LockBits(new rect(X,Y,width,height),
ImageLockMode.ReadOnly, bitmap.PixelFormat);
What seems to be the issue is bitmapData.Scan0 gives me
IntPtr
of the top left corner of the rectangle. When I copy using memcpy, it copies the contiguous region in memory upto the specified length.
memcpy(bitmapdest.Scan0, bitmapData.Scan0, new UIntPtr((uint) (rect.Width*rect.Height*3)));
If following is my bitmap data,
a b c d e <br />
f g h i j<br />
k l m n o<br />
p q r s t <br />
and if the rectangle portion is required
(2, 1, 3 ,3)
i.e, the region
<br />
g h i<br />
l m n<br />
q r s<br />
using memcpy gives me bitmap with the following region
<br />
g h i<br />
j k l<br />
m n o<br />
How can I still use Lockbits and achieve rectangluar region copy?