Jump to content
Sign in to follow this  
  • entries
    37
  • comments
    46
  • views
    22086

Update on 2D engine

Sign in to follow this  
Drakkcon

226 views

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  


0 Comments


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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!