Libgdx: TexturePacker and PixmapPacker should get 9-patch support

Created on 25 Oct 2017  ·  4Comments  ·  Source: libgdx/libgdx

Issue details

TextureAtlas.AtlasRegion has the fields "pads" and "splits" for 9-patch information.
These fields get populated if the info is loaded from a .atlas file with the TextureAtlas (FileHandle packFile) constructor.

However, if you use TexturePacker.pack or PixmapPacker.pack to pack your TextureAtlas at runtime using the generateTextureAtlas method, this 9-patch information is lost. There's no way to give TexturePacker or PixmapPacker this information when packing.

I would suggest that there should be a version of the pack methods in TexturePacker and PixmapPacker which accepts this 9-patch info so that it comes out in the regions from generateTextureAtlas.

Reproduction steps/code

I wrote a sort of workaround in this code here which assumes the user will be packing from only one TextureAtlas and that all the names of all the textures will exactly match. However, this is an ugly hack. It would be better if TexturePacker and PixmapPacker handled this.

Version of LibGDX and/or relevant dependencies

All.

Please select the affected platforms

All platforms.

enhancement

Most helpful comment

I've added this personally for my projects, and Is a handy feature. Ill see about making a PR for it soon.

All 4 comments

I've added this personally for my projects, and Is a handy feature. Ill see about making a PR for it soon.

Looking forward to that! :)

Anything happen with this? @Tom-Ski :)

Pushed support to PixmapPacker for this. TexturePacker already supports this.
See https://github.com/libgdx/libgdx/commit/64f2d9d08223f67a2cf64e2c8daa1fc4839d158f

Was this page helpful?
0 / 5 - 0 ratings