• 10
• 10
• 12
• 14
• 15
• entries
37
46
• views
22013

# Update on 2D engine

201 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.

There are no comments to display.