Convert TileSet Atlas Merge input images to RGBA8 to match output, if needed

(cherry picked from commit dc2aa69c46)
This commit is contained in:
Rakka Rage 2023-08-23 15:54:43 -04:00 committed by Yuri Sizov
parent 4944a07044
commit 22560c5bf0
1 changed files with 5 additions and 1 deletions

View File

@ -60,6 +60,10 @@ void AtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> p_atla
int line_height = 0;
for (int source_index = 0; source_index < p_atlas_sources.size(); source_index++) {
Ref<TileSetAtlasSource> atlas_source = p_atlas_sources[source_index];
Ref<Image> input_image = atlas_source->get_texture()->get_image();
if (input_image->get_format() != Image::FORMAT_RGBA8) {
input_image->convert(Image::FORMAT_RGBA8);
}
merged_mapping.push_back(HashMap<Vector2i, Vector2i>());
// Layout the tiles.
@ -78,7 +82,7 @@ void AtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> p_atla
if (dst_rect_wide.get_end().x > output_image->get_width() || dst_rect_wide.get_end().y > output_image->get_height()) {
output_image->crop(MAX(dst_rect_wide.get_end().x, output_image->get_width()), MAX(dst_rect_wide.get_end().y, output_image->get_height()));
}
output_image->blit_rect(atlas_source->get_texture()->get_image(), src_rect, dst_rect_wide.get_center() - src_rect.size / 2);
output_image->blit_rect(input_image, src_rect, dst_rect_wide.get_center() - src_rect.size / 2);
}
// Add to the mapping.