The value at 0x50 is to fix the size. Previously it was 512 * 512 (one byte per pixel). I changed it to 512 * 512 * 4 (4 bytes per pixel).
At 0x58 I've set the bitsPerPixel to 32.
The next 4 values are the masks for R, G, B and A: 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF
Before fixing the header, the image displayed only used 1/4 from the image data and it was all corrupted. It used 8 bits per pixel to display it (instead of 32).
Here is how the image is originally exported.
If you want, I can upload the data files I used to export this images from.
Is there anything I can do to remove the smudges programatically?