Git Product home page Git Product logo

sdl2-lz4-image's Introduction

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:

sdl2-lz4-image's People

Contributors

sgiraudot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

mbabuskov

sdl2-lz4-image's Issues

compiling problem

I tried to compiling it as wrote on the README:

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

But strangly make fail, with the following error:
ARMbian/Ubuntu (aarch64):

make[2]: ***  Aucune règle pour fabriquer la cible « /usr/lib/aarch64-linux-gnu/libSDL2.so /usr/lib/aarch64-linux-gnu/libSDL2_image.so /usr/lib/aarch64-linux-gnu/liblz4.so », nécessaire pour « SDL_lz4_image_converter ». Arrêt.
make[1]: *** [CMakeFiles/Makefile2:87 : CMakeFiles/SDL_lz4_image_converter.dir/all] Erreur 2
make: *** [Makefile:91 : all] Erreur 2

On Arch Linux ARM (aarch64):

make[2]: ***  Aucune règle pour fabriquer la cible « /usr/lib/libSDL2.so /usr/lib/libSDL2_image.so /usr/lib/liblz4.so », nécessaire pour « SDL_lz4_image_converter ». Arrêt.
make[1]: *** [CMakeFiles/Makefile2:87: CMakeFiles/SDL_lz4_image_converter.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

On both systems, the libs are already there.

This gcc call in root dir of the git clone worked fine on Arch Linux ARM and ARMbian (.c file must be at first place in ARMbian else it ld fail: référence indéfinie vers « SDL_RWwrite » etc)

gcc  src/SDL_lz4_image.c convert.c \
  -Iinclude -I/usr/include/SDL2 -I/usr/include \
  -lSDL2 -lSDL2_image -llz4 \
  -o convertlz4

I don't know cmake, so I'm not sure about the place of the error.

It could maybe be better to call it convertSDL2_lz4 or something like that to avoid conflicts with ImageMagicks convert

Thanks for your great work !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.