Update on 2D engine

Published August 13, 2005
Advertisement
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.
Previous Entry Beginning my RPG project
Next Entry Update
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

..............

549 views

Untitled

956 views

Untitled

979 views

Back

972 views

I'm finally back

1007 views

Random updates

881 views

Hou zhou bu jien

908 views

Update

999 views
Advertisement