This project demonstrates a solver for 2D packing problem.
We utilize this algorithm.
C++ is required to build.
Just download/clone all .h/.cpp files.
Same example is shown in main.cpp.
To pack multiple images, use "ImagePacker" class,
#include "imagePacker.h"
...
ImagePacker packer(1024, 1024);
and call "insert" method.
Image img;
... setting img color, width/height
int id = 0;
if (packer.insert(image, id))
{
...
}
"insert" method returns true and assign id when success to insert.
Once success to insert an image to the packer, you can access a node with ID.
auto* nodePtr = packer.getNode(id);
Finally, to save the atlas image, call "save()" method.
packer.save("result.bmp");
nossey
This project uses CImg library for image process.
CImg is distributed under CeCILL License
(If you want to use your own image library, please modify "Image" class and related functions. (e.g. Image.getWidth(), fillPixel(), ...))
This project is free for use.
But we do not take any responsibilities for any risks and damages by using this project codes.