GithubHelp home page GithubHelp logo

wangpengcv / 2d-packing-problem Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nossey/2d-packing-problem

0.0 1.0 0.0 480 KB

This project produces a simple bin packing solver.

C++ 99.99% C 0.01%

2d-packing-problem's Introduction

2D packing problem

This project demonstrates a solver for 2D packing problem.
We utilize this algorithm.

BinPacking

Getting Started

Prerequisties

C++ is required to build.

Installation

Just download/clone all .h/.cpp files.

Example

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");

Author

nossey

License

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(), ...))

Disclaimer

This project is free for use.
But we do not take any responsibilities for any risks and damages by using this project codes.

2d-packing-problem's People

Contributors

nossey avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.