Original Post
I'm writing a BMP loader for a game engine I'm making. It was all working fine till I added this bit of code in to flip the scan lines so they were the right way round
teximage is the image (it's an array of unsigned chars) that will contain the image with the flipped scanlines. bmpimage is the image I've loaded from the bmp file (it's also an array of unsigned chars). The image I run through here is uncompressed and 24-bit. It works fine with a couple of BMP's I got from the book OpenGL Game Programming but when I make a BMP in photoshop and load it using my loader the colour channels seem to be offset from each other. If I skip out the scan line flipping code above they load fine only they're upside down. Does anybody know what's going on?
[edited by - Monder on May 5, 2003 8:50:23 AM]
unsigned int f = ImageSize - (BmpInfoHead.biWidth * 3);
for(unsigned int i=0; i < ImageSize; i+=(BmpInfoHead.biWidth *3))
{
memcpy(&teximage[i], &bmpimage[f](BmpInfoHead.biWidth*3));
f-= (BmpInfoHead.biWidth * 3);
}