I can answer the last issue, on the shifted image.
DIB has multiple formats, specified by the "Compression" option in the header. This isn't limited to actual compression formats, but contains various formats differing from the standard, so it should always be checked before processing the data. If the format is using compression type 3 (BI_BITFIELDS
) instead of 0 (BI_RGB
), then the image data starts with three Int32 bit masks that specify which bits to read to get the R, G and B components of a 32-bit pixel. Generally, those are set to the default expected values (0x00FF0000 for R, 0x0000FF00 for G and 0x000000FF for B), so if they are, you don't really need to do anything special with the data itself, but either way, you still need to skip these twelve bytes, of course, or they'll show up as three pixels on your image.
So clearly, your DIB methods are lacking. I wrote my own; you can check them out in this answer: