mbabuskov / SDL2-LZ4-Image

A compressed SDL_Surface format using the LZ4 compression library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SDL2 LZ4 Image

Note: this repository is just a mirror of the official repository on Framagit, which should be considered as the most up-to-date and reliable source for SDL2 LZ4 Image.

This repository provides a way to convert images to a compressed SDL_Surface format using the LZ4 compression library.

It also provides a way to create your own benchmark.

This format was created for the game Superfluous Returnz. The logic behind it is explained in this blog post along with results of a benchmark and additional explanations.

Compiling and running

This program has only been tested on GNU/Linux but should be compatible on every platform compatible with SDL2 and LZ4.

Configuration is handled by CMake:

$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ make

Compressing/decompressing

To convert an image into the SDL2 LZ4 format, run:

$ ./convert [input.png/bmp/whatever] [output.lz4]

Add -hc at the end of the command to activate the LZ4 HC algorithm (more efficient but longer to compress).

To convert images in batch, use:

$ ./SDL_lz4_image_converter  file1.bmp file2.png file3.sdl_surface.lz4 [...]

BMP/PNG images will be compressed and saved using the same name with the .sdl_surface.lz4 extensions, LZ4 images will be decompressed and saved with the same name with the .png extension.

Profiling/benchmark

To profile on a set of images, run:

$ ./profile file1.bmp file2.png file3.sdl_surface.lz4 [...]

This program outputs three values separated by a white space:

  • the total time taken to read this files from disk to memory
  • the total time taken to create the SDL_Surface structures
  • the total time taken to create the SDL_Texture structures

In order to run a full benchmark on BMP/PNG/PNG(quant)/LZ4/LZ4(HC) formats, run (from the root directory of the repository):

$ python3 benchmark.py file1.bmp file2.png [...]

All provided images will be first converted to all tested formats, and then the profiling program will be used to compare them.

Note: this script may only work on GNU/Linux, and requires the following dependencies:

About

A compressed SDL_Surface format using the LZ4 compression library.

License:zlib License


Languages

Language:C 47.8%Language:CMake 41.6%Language:Python 10.6%