Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Update on 2D engine

Sign in to follow this  


Today I successfully used my new File Format. It's a paletted file format similar to an 8-bit .bmp file. Basically I added a name, creator, and description field, which can all be an undefined length, and I removed a lot of what was in the bitmap header. The palette is the same except that it's Big Endian. The data field is not written upside down, and there are no padded bytes on the ends of lines. There are also no size limitations (BMP forces an exponent of 2). Because of the slimmed-down header and lack of padding, my files are a bit smaller too.

The idea was to make a format that is easier for me to use, because it contains data fields that I need, and removes all of the extraneous ones from the .bmp format

The hardest part making this format was the loader. Upon loading my displayer kept seg-faulting. It turns out, the saver was saving data that was mis-aligned by just a few bytes, screwing up the whole file. I rewrote the saver, and now everything works perfectly.

Here is the file format:

Image file:
extension -- .aibp -- Aerial Image Binary Paletted

--used to make sure it is loadable
float fileFormatVersion

int sizeOfImageName
int sizeOfCreatorName
int sizeOfDescription

char imageName[sizeOfImageName]
char creatorName[sizeOfCreatorName]
char description[sizeOfDescription]

unsigned char bitsPerPixel
unsigned int width, height
unsigned int dataSize

--big endian, RGB, omit the reserved member on save
SDL_Color palette[256]

Uint8 data[dataSize]

The reason I have the 'sizeof' fields instead of just null-terminating my name/creator/description strings, is because the fields make making a loader MUCH faster. I think the loading itself is faster too, because otherwise I would have to write a loop that looks at each byte to see if it's a null terminator. I think being able to be lazy is worth 12-bytes.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!