| 2650 | } |
| 2651 | |
| 2652 | static std::vector<clip_image_u8_ptr> slice_image(const clip_image_u8 * img, const slice_instructions & inst) { |
| 2653 | std::vector<clip_image_u8_ptr> output; |
| 2654 | |
| 2655 | // resize to overview size |
| 2656 | clip_image_u8_ptr resized_img(clip_image_u8_init()); |
| 2657 | img_tool::resize(*img, *resized_img, inst.overview_size, inst.interpolation_overview, |
| 2658 | inst.padding_overview, inst.pad_color_overview); |
| 2659 | output.push_back(std::move(resized_img)); |
| 2660 | |
| 2661 | if (inst.slices.empty()) { |
| 2662 | // no slices, just return the resized image |
| 2663 | return output; |
| 2664 | } |
| 2665 | |
| 2666 | // resize to refined size |
| 2667 | clip_image_u8_ptr refined_img(clip_image_u8_init()); |
| 2668 | img_tool::resize(*img, *refined_img, inst.refined_size, inst.interpolation_refined, |
| 2669 | inst.padding_refined, inst.pad_color_refined); |
| 2670 | |
| 2671 | // create slices |
| 2672 | for (const auto & slice : inst.slices) { |
| 2673 | int x = slice.x; |
| 2674 | int y = slice.y; |
| 2675 | int w = slice.size.width; |
| 2676 | int h = slice.size.height; |
| 2677 | |
| 2678 | clip_image_u8_ptr img_slice(clip_image_u8_init()); |
| 2679 | img_tool::crop(*refined_img, *img_slice, x, y, w, h); |
| 2680 | output.push_back(std::move(img_slice)); |
| 2681 | } |
| 2682 | |
| 2683 | return output; |
| 2684 | } |
| 2685 | |
| 2686 | private: |
| 2687 | static clip_image_size get_best_resize(const clip_image_size & original_size, int scale_resolution, int patch_size, bool allow_upscale = false) { |
nothing calls this directly
no test coverage detected