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:

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.