Locks the Bitmap and return the raw data.
Converting between pixel formats is expensive so where possible
you should try and use the current pixel format of the Bitmap.
If you specify a pixel format which is different from the
current one try and specify ImageLockMode.ReadOnly as this obviates
the need to write the pixels back to the original image.
Typically you will want to lock the entire area of the Bitmap,
but for convenience you can lock a smaller area using the rect
parameter. However it is important to note that the Scan0 property
of the returned BitmapData specifies a pointer to a byte, so the
left coordinate of the rectangle you provide must be on a byte
boundary. If this is not the case an exception will be
raised. |