I remember reading an article written by the lead programmer of an indie project on iOS. His project (not a game) was an overnight sensation with over 10,000 downloads. The amount of money he made through those sales totaled something like $300 USD.
To write the file, you write out the correct number of bytes for each header field and then the image data from your buffer. I prefer not to make assumptions about integer size and thus header size. "long" may or may not be 4 bytes, depending in the platform, but can be guaranteed to be no less than four bytes. Always explicitly write out the correct number of bytes per field and never rely on "sizeof(image_header)" when reading the file. On some 64-bit systems, "long" might be 8 bytes, in which case reading or writing "sizeof(long)" will not get you what you expect.
Yes bmp sucks but I feel so close. This code works perfectly with bmp only one flaw when I try to free the pixels I get heap corruption. !!! The only reason I use this format because I dont want to overload my head with compression and decompression, as I understand and correct me if am wrong everything else including targa uses compression.
Compression is optional in TGA files. I've never used it.
First off, I wouldn't recommend using BMP as a texture storage and loading format. Ideally, you'd create your own format, but barring that, I'd use TGA. It is far easier to load as the format just makes sense. BMP is highly screwed up, as you've noticed. The pixels are not stored as you would expect. Padding *may* be added per scanline, which makes looking at the file with a hex editor all but useless.
If you are insistent on using BMP, do some studying:
For the past few days I have been learning assembly and I was wondering how to display graphics on the screen.
I'm doing this just for fun because I feel like I'm starting to burn out on my main game project and I thought I would do something fun like learn assembly. However displaying text on a console wasn't very exciting for me. So I'm taking it to the next level.
So, does anyone know how to start game development with assembly?
Why do you want to do this? What do you hope to gain? Yes, there is still the ability to write optimized assembly, but you can write just as optimized code and write it far quicker in a higher level language with today's compilers. I certainly recommend learning assembly, but for no other reason than to know what is going on behind the scenes. It's a step up from writing code directly in binary. It's like learning how to fix an engine to get your driver's license.