TexturePacker with JPEG support

Any community contributions to libgdx go here! Some may get included in the core API when permission is granted.

TexturePacker with JPEG support

Postby megasoft78 » Sat Jun 02, 2012 7:04 am

Hi all,
I'm new on this forum and I want first of all to thanks Mario for this amazing framework.
I'm currently create a simple puzzle game as my first Android game and I'm using libgdx.
My game use 3d rendering done with Blender and YafaRay and because they can be big (about 800KB in png) I think JPEG format fit better for this kind of image.
I was using TexturePacker on my desktop start method to automatically group them into atlas images and everything works fine except for the file format.
Actually TexturePacker does support only png format as output and because it was very easy I did few changes to make it support PNG and JPEG based on a parameter you pass (by default is PNG).
If you want to use just add the following line to your Settings object:
Code: Select all
settings.defaultFileFormat = FileFormat.JPEG;


I attached the patch and the file.
TexturePacker JPEG support.zip
(10.23 KiB) Downloaded 46 times


Enjoy,
megasoft78
megasoft78
 
Posts: 5
Joined: Fri May 18, 2012 4:28 pm

Re: TexturePacker with JPEG support

Postby megasoft78 » Sat Jun 02, 2012 7:38 am

Hi guys,
here a small update suggested by bach on irc (thanks bach).
I added support for compression quality. The value need to be between 0 (max compression) and 1 (max quality) and by default is 0.9

Here the sample code:
Code: Select all
settings.defaultFileFormat = FileFormat.JPEG;
settings.defaultImageQuality = 0.9f;


TexturePacker with JPEG support.zip
(17.83 KiB) Downloaded 55 times


megasoft78
megasoft78
 
Posts: 5
Joined: Fri May 18, 2012 4:28 pm

Re: TexturePacker with JPEG support

Postby mzechner » Sat Jun 02, 2012 9:01 am

Awesome, applied the patch, commited to SVN! Thanks a bunch.
mzechner
Site Admin
 
Posts: 4596
Joined: Sat Jul 10, 2010 3:50 pm

Re: TexturePacker with JPEG support

Postby megasoft78 » Sat Jun 02, 2012 11:57 am

mzechner wrote:Awesome, applied the patch, commited to SVN! Thanks a bunch.


No problem. :)

megasoft78
megasoft78
 
Posts: 5
Joined: Fri May 18, 2012 4:28 pm


Return to Libgdx Contributions

Who is online

Users browsing this forum: No registered users and 1 guest

x