-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Describe the bug
When using --max-size or --scale together with --fix-size, the output image width or height is not aligned to a multiple of 4 as expected.
To Reproduce
Steps to reproduce the behavior:
- Add
--fix-sizeor-fsto arguments. - Add
--max-size 10to arguments. - Use any PNG file as input.
- Run the command. The generated DDS file will have a width or height not divisible by 4 (e.g. 10x10).
Expected behavior
The output image should have both width and height as multiples of 4.
This is required for BC compression formats and should be ensured by --fix-size.
System (please complete the following information):
Not relevant.
Additional context
fix_size is only used in filter_decode_png.cpp and not applied in filter_scale_image.cpp.
todds/src/pipeline/filter_decode_png.cpp
Lines 68 to 73 in ca6c521
| if (_fix_size && (first.width() % 4 != 0 || first.height() % 4 != 0)) [[unlikely]] { | |
| result = fix_image_size(*result, _mipmaps); | |
| const auto& new_first = result->get_image(0UL); | |
| file_data.width = new_first.width(); | |
| file_data.height = new_first.height(); | |
| } |
todds/src/pipeline/filter_scale_image.cpp
Lines 37 to 56 in ca6c521
| auto width = (input_image.width() * _scale) / 100U; | |
| auto height = (input_image.height() * _scale) / 100U; | |
| if (_max_size > 0U && (width > _max_size || height > _max_size)) { | |
| if (width > height) { | |
| const double ratio = static_cast<double>(_max_size) / static_cast<double>(width); | |
| width = _max_size; | |
| height = static_cast<std::size_t>(static_cast<double>(height) * ratio); | |
| } else { | |
| const double ratio = static_cast<double>(_max_size) / static_cast<double>(height); | |
| height = _max_size; | |
| width = static_cast<std::size_t>(static_cast<double>(width) * ratio); | |
| } | |
| } | |
| if (width == 0 || height == 0) { | |
| _updates.emplace(report_type::pipeline_error, | |
| fmt::format("Could not scale {:s} from ({:d}, {:d}) to ({:d}, {:d}).", _paths[img->file_index()].first.string(), | |
| input_image.width(), input_image.height(), width, height)); | |
| return nullptr; | |
| } |
Metadata
Metadata
Assignees
Labels
No labels