This repository was archived by the owner on Jan 27, 2026. It is now read-only.
Sprite fitting layout, related to SMARTSPRITES-64 and SMARTSPRITES-72#1
Open
planetbeing wants to merge 2 commits intocarrotsearch:masterfrom
Open
Sprite fitting layout, related to SMARTSPRITES-64 and SMARTSPRITES-72#1planetbeing wants to merge 2 commits intocarrotsearch:masterfrom
planetbeing wants to merge 2 commits intocarrotsearch:masterfrom
Conversation
…y to pack subimages as tightly as possible to reduce total image size.
Member
|
Hi! Thanks for the patch! Compact image layout, even if not optimal (an optimal layout problem is probably NP-complete anyway), would be a big improvement. Later this week I'll review the path, fix unit tests, write some new ones, update the documentation and merge the whole thing. Thanks! S. |
…t images. AreaComparator should make sure to say they are different so that the list of images to place can be complete.
stanislawosinski
pushed a commit
that referenced
this pull request
Apr 12, 2013
Fixed java lib path in windows commandline batch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'm not really a Java developer by any means, but I just thought I'd contribute this rough patch to do a reasonably good job at fitting sprites tightly in the generated image. It uses a greedy algorithm, which is probably suboptimal for this type of problem, but on my site it generates good results with no obvious errors.
The patch does change your hashCode algorithm for images, which I found generated quite a lot of collisions even in a small space if images are similar. I don't think there's really going to be much of a significant penalty to CRC'ing every pixel on modern machines, and a collision-free hashCode was necessary for TreeSet to function properly (at least in my naive implementation).
The patch also fails some of your test cases, but I think it's just because the order of the images shifted from the order expected in your tests. Due to the implementation, in all cases, images will be placed in order of total size descending.
Thanks for developing this excellent piece of software!