abzico / texpackr

Textures packer into texture atlas, spit out atlas, and meta data. Aim to support .png, and .dds

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

donate

texpackr

Textures packer into texture atlas, spit out atlas, and meta data. Aim to support .png, and .dds

texpackr screenshot

Build

Based on autotools.

  • ./autogen.sh
  • ./configure
  • make
  • (optional) make check
  • make install - then you will get executable file texpackr, shared and dynamic libraries along with header files necessary to develop the program.

Dependencies

ndk-build support

This project has Android.mk build support for Android.

To be able to use Android.mk to build, you need to download the following dependencies source code to your system

  • libpng - download libpng source then place at ../libpng from this project directory, then use our Android.mk by following instruction there.
  • libhashmap_c - clone source code from abzico/hashmap_c then place at ../hashmap_c

Meta File Format

When export into a spritesheet and meta file, the latter has the following format. You can see texcoord_min_u and other similar names. That's the pre-computed texture coordinate for such sprite. So user doesn't have to query it, compute texture coordinate for each sprite, then save it somewhere to in memory to use in rendering.

# generated by texpackr (....), this is comment line and ignored by texpackr's processor
sheet_width sheet_height
number_of_sprites
path/to/sprite/1.png offset_x offset_y size_x size_y texcoord_min_u texcoord_max_u texcoord_min_v texcoord_max_v
path/to/sprite/2.png offset_x offset_y size_x size_y texcoord_min_u texcoord_max_u texcoord_min_v texcoord_max_v
...
path/to/sprite/N.png offset_x offset_y size_x size_y texcoord_min_u texcoord_max_u texcoord_min_v texcoord_max_v

Example is as follows

# generated by texpackr (....), this is comment line and ignored by texpackr's processor
1024 1024
8
images/1.png 0 0 380 231 0.000000 0.371094 0.000000 0.225586
images/2.png 380 0 128 87 0.371094 0.496094 0.000000 0.084961
images/3.png 0 231 636 264 0.000000 0.621094 0.225586 0.483398
images/4.png 0 495 400 400 0.000000 0.390625 0.483398 0.874023
images/5.png 636 231 256 259 0.621094 0.871094 0.225586 0.478516
images/6.png 400 495 400 260 0.390625 0.781250 0.483398 0.737305
images/7.png 400 755 510 254 0.390625 0.888672 0.737305 0.985352
images/8.png 508 0 128 151 0.496094 0.621094 0.000000 0.147461

TODO

Phase I

  • packing algorithm for multiple images into a single texture atlas
  • read .png (support 1-4 channels: gray, gray-alpha, RGB, and RGBA) image as input
  • save into a texture atlas as .png image
  • read .jpg image as input
  • save into a texture atlas as .dds image
  • save meta data into file (with file extension .tpr)
  • parse meta file and get sheet + sprites info
  • C API
  • command line for all major operations supported by C API

Phase II

  • ability to scale input images then output it
  • cut out alpha pixels to maximize capacity of sprite storage in result spritesheet
  • spacing between sprites packed in sheet

License

MIT, ABZI

About

Textures packer into texture atlas, spit out atlas, and meta data. Aim to support .png, and .dds

License:MIT License


Languages

Language:C 93.8%Language:Makefile 4.6%Language:M4 1.4%Language:Shell 0.1%