Access violation is caused by wrong arguments. The API just hits memory beyond either source or destination buffers.
You are already aware of GetBPP
issue, which is not small but severe (you should have your code snippet updated respectively).
Another issue is the last MFCopyImage
argument. It's height, not width. Since width is typically smaller you are likely to have a buffer overrun.
Additionally you are assuming minimal stride. Effectively you might have a larger one. In this case you would see a skew effect on the copied image and not access violation.