I was trying to read bitmaps manually by just loading the files and reading bytes from them, and I noticed something very odd. I got some unexpected results when I read or manipulated the data for bitmaps in which the width and/or height is not divisible by 4, but it always seemed to work fine when they are divisible by 4.
I looked though the header information I was getting, and weirdly, the file size and image size fields (I don't know why it needs both, one's just the other + 54 for the header size, but whatever) are larger than they should be. They're still a difference of 54, but the image size is bigger than the actual number of pixels * bytes per pixel (3 for 24 bit color).
This seemed to be the cause of a problem when I tried to save a bitmap, so even when I tried to just read one and write it directly to another one, it wouldn't open in Paint or any image viewer. I suspected that it was because it thinks the file size is larger than it actually is, because the header info is wrong (which makes me wonder, what is Paint storing in the extra data?).
So I tried adjusting those 2 fields to equal the actual amount of bytes of my pixels (+ 54 for the file size), and now it will open, but looks oddly skewed. I thought that maybe it's padding the scan lines with blank pixels or something, but that would be wasteful, and nothing in the header seems to indicate any amount of padding. So I tried copying the data first before saving it, and copied pixel by pixel, so that it would come in correctly, but that doesn't fix it either.
I've used bitmaps before, and never had a problem like this. What could be wrong with it? And no, I DON'T have source code, but for God's sake, this is a common enough format that someone should understand it anyway, isn't it?