CodeWalrus

Development => PC, Mac & Vintage Computers => Topic started by: rowan_futurerave on November 16, 2018, 08:46:55 AM

Title: Custom Bitmap Format
Post by: rowan_futurerave on November 16, 2018, 08:46:55 AM
Hi all. Am thinking of creating a custom bitmap format due to awkwardness I am experiencing with a lib (glaux.lib) which has been deprecated.

What would anyone else add to a custom bitmap format?

Not RLE. Possibly encryption. What else??

>:D

*edit - one idea - strangely ordered scanlines
Title: Re: Custom Bitmap Format
Post by: gameblabla on November 16, 2018, 01:39:14 PM
You could use a raw format (RGB565, RGB8, RGB555 etc...) then compress it with an algorithm known to decompress pretty fast such as lz4.If your compiler is somewhat modern, then the best choice would probably be zStandard. It has higher compression rates than lz4 while being much faster than its other alternatives. (although lz4 is still faster)
If your platform is using a Motorola 68000 cpu, stef made a fast decompressor called lz4w for that CPU family. It can be found in assembly form here :https://github.com/Stephane-D/SGDK/blob/e8d6e7e6668579e1299e19f1c024dd8dc16d430e/src/tools_a.s (https://github.com/Stephane-D/SGDK/blob/e8d6e7e6668579e1299e19f1c024dd8dc16d430e/src/tools_a.s)
Function call in C is as such :u16 lz4w_unpack(const u8 *src, u8 *dest);
On the same platform, aplib is also another good alternative but it's a fair amount slower.
As for encryption, well it's just easier to do it outside out of the file format because that would require more work (separate the actual image data from the header then compare it to a hash etc...).
Make sure the file format meets your needs only. On the Atari falcon, space was of no concern so i simply made a raw RGB565 format except flipped for Big endian cpus. Of course on little endian machines, this is not a concern and you can go for compression for example.
Title: Re: Custom Bitmap Format
Post by: rowan_futurerave on November 16, 2018, 11:29:58 PM
Nice thoughts gameblabla you have inspired me, I now have decided on the file spec. Woot  (-_(//));