Useful for e.g. packing rectangular textures into an atlas. Does not do rotation.
This library currently uses the Skyline Bottom-Left algorithm. Not necessarily the awesomest packing method, but better than the totally naive one in stb_truetype (which is primarily what this is meant to replace).
| Modifier and Type | Field and Description |
|---|---|
| public static final int | STBRP__MAXVAL
Mostly for internal use, but this is the maximum supported coordinate value. |
| public static final int | STBRP_HEURISTIC_Skyline_BF_sortHeight
Packing heuristics Enum values: |
| public static final int | STBRP_HEURISTIC_Skyline_BL_sortHeight
Packing heuristics Enum values: |
| public static final int | STBRP_HEURISTIC_Skyline_default
Packing heuristics Enum values: |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public static native void | nstbrp_init_target(long context, int width, int height, long nodes, int
the number of structs in num_nodes)nodesUnsafe version of: |
| public static native int | nstbrp_pack_rects(long context, long rects, int
the number of structs in num_rects)rectsUnsafe version of: |
| public static native void | nstbrp_setup_allow_out_of_mem(long context, int allow_out_of_mem)
Unsafe version of: |
| public static native void | |
| public static void | stbrp_init_target(STBRPContext
an context, int STBRPContext structthe rectangle width width, int the rectangle height height, STBRPNode.an array of nodesSTBRPNode structsInitialize a rectangle packer to: pack a rectangle that is |
| public static int | Returns: 1 if all of the rectangles were successfully packed and 0 otherwisean context, STBRPRect.STBRPContext structan array of rectsSTBRPRect structsAssigns packed locations to rectangles. |
| public static void | stbrp_setup_allow_out_of_mem(STBRPContext
an context, boolean STBRPContext struct1 to allow running out of temporary storage allow_out_of_mem)Optionally call this function after init but before doing any packing to change the handling of the out-of-temp-memory scenario, described in
|
| public static void | stbrp_setup_heuristic(STBRPContext
an context, int STBRPContext structthe packing heuristic heuristic)Optionally select which packing heuristic the library should use. |
| STBRP__MAXVAL | back to summary |
|---|---|
| public static final int STBRP__MAXVAL Mostly for internal use, but this is the maximum supported coordinate value. | |
| STBRP_HEURISTIC_Skyline_BF_sortHeight | back to summary |
|---|---|
| public static final int STBRP_HEURISTIC_Skyline_BF_sortHeight Packing heuristics Enum values: | |
| STBRP_HEURISTIC_Skyline_BL_sortHeight | back to summary |
|---|---|
| public static final int STBRP_HEURISTIC_Skyline_BL_sortHeight Packing heuristics Enum values: | |
| STBRP_HEURISTIC_Skyline_default | back to summary |
|---|---|
| public static final int STBRP_HEURISTIC_Skyline_default Packing heuristics Enum values: | |
| STBRectPack | back to summary |
|---|---|
| protected STBRectPack() | |
| nstbrp_init_target | back to summary |
|---|---|
| public static native void nstbrp_init_target(long context, int width, int height, long nodes, int num_nodes) Unsafe version of:
| |
| nstbrp_pack_rects | back to summary |
|---|---|
| public static native int nstbrp_pack_rects(long context, long rects, int num_rects) Unsafe version of:
| |
| nstbrp_setup_allow_out_of_mem | back to summary |
|---|---|
| public static native void nstbrp_setup_allow_out_of_mem(long context, int allow_out_of_mem) Unsafe version of: | |
| nstbrp_setup_heuristic | back to summary |
|---|---|
| public static native void nstbrp_setup_heuristic(long context, int heuristic) Unsafe version of: | |
| stbrp_init_target | back to summary |
|---|---|
| public static void stbrp_init_target(STBRPContext context, int width, int height, STBRPNode. Initialize a rectangle packer to: pack a rectangle that is You must call this function every time you start packing into a new target. There is no "shutdown" function. The Note to guarantee best results, either:
If you don't do either of the above things, widths will be quantized to multiples of small integers to guarantee the algorithm doesn't run out of temporary storage. If you do #2, then the non-quantized algorithm will be used, but the algorithm may run out of temporary storage and be unable to pack some rectangles.
| |
| stbrp_pack_rects | back to summary |
|---|---|
| public static int stbrp_pack_rects(STBRPContext context, STBRPRect. Assigns packed locations to rectangles. The rectangles are of type Rectangles which are successfully packed have the You should not try to access the To pack into another rectangle, you need to call
| |
| stbrp_setup_allow_out_of_mem | back to summary |
|---|---|
| public static void stbrp_setup_allow_out_of_mem(STBRPContext context, boolean allow_out_of_mem) Optionally call this function after init but before doing any packing to change the handling of the out-of-temp-memory scenario, described in
| |
| stbrp_setup_heuristic | back to summary |
|---|---|
| public static void stbrp_setup_heuristic(STBRPContext context, int heuristic) Optionally select which packing heuristic the library should use. Different heuristics will produce better/worse results for different data sets. If you call init again, this will be reset to the default.
| |